PHP Simplicity Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

The latest version of Simplicity oF Upload is 1.3.2.

Author Topic: Add a contact field to the form...  (Read 9618 times)

0 Members and 1 Guest are viewing this topic.

eakucera00

  • Guest
Add a contact field to the form...
« on: August 15, 2005, 08:41:04 PM »

i would like to add a field that forces the user to enter there e-mail address or there phone number or name..  and when submitted, the response e-mail would contain the user's contact info they provided.  This would be helpful to identify who uploaded what files.

any help would be greatly appreciated.  your welcome to e-mail me directly.

thanks,

Ernie
Logged

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 222
    • View Profile
    • PHP Simplicity
Re: Add a contact field to the form...
« Reply #1 on: August 19, 2005, 06:36:03 AM »

open functions.php and look for:
Code: [Select]
function MailUploaded() {
   global $txt, $uploaded, $errors, $admin_email, $URL;

  //we put an introduction and the IP address of the user who attempted to upload
   $message = $txt['mail']['head'];
   $message.= "$_SERVER[REMOTE_ADDR]\n\n";

replace it with:
Code: [Select]
function MailUploaded($extra_message = null) {
   global $txt, $uploaded, $errors, $admin_email, $URL;

  //we put an introduction and the IP address of the user who attempted to upload
   $message = $txt['mail']['head'];
   $message.= "$_SERVER[REMOTE_ADDR]\n$extra_message\n\n";   


also look for (in the same file):
Code: [Select]
//start the loop ..
   for ($i = 0; $i < $num_files; $i++) {
      $form .= '
            <input type="file" name="SFUfile[]" size="20" '.$disabled.'/><br />';
   }

add after:
Code: [Select]
$form.= '<br />Email: <input type="text" name="email" /><br />';

in upload.php, look for:
Code: [Select]
if (isset($_POST['SFUsubmit'])) {
add after:
Code: [Select]
   if (!isset($_POST['email']) || !preg_match('~^[_0-9a-z\-\.]+@[_0-9a-z\-\.]+\.[_0-9a-z\-\.]+$~i',$_POST['email'])) {
      echo 'You did not enter your email!';
      html_footer();
      exit;
   }

also look for:
Code: [Select]
   if ($notify_admin == true)
      MailUploaded();

replace with:
Code: [Select]
   if ($notify_admin == true)
      MailUploaded($_POST['email']);

this should do it :)
« Last Edit: November 18, 2010, 08:35:40 AM by Saleh »
Logged

We don't need a reason to help people

Ernie

  • Guest
Re: Add a contact field to the form...
« Reply #2 on: August 21, 2005, 12:40:41 PM »

   if (!isset($_POST['email']) || !preg_match('^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$',$_POST['email'])) {
      echo 'You did not enter your email!';
      html_footer();
      exit;
   }



everytime i try entering my e-mail address and submit it always states that i "did not enter my e-mail address".  I think something is wrong with the validation.  other than that it looks like it should work.

thanks for your help again.
Logged

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 222
    • View Profile
    • PHP Simplicity
Re: Add a contact field to the form...
« Reply #3 on: August 22, 2005, 03:38:16 AM »

replace:
Code: [Select]
if (!isset($_POST['email']) || !preg_match('^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$',$_POST['email'])) {with:
Code: [Select]
if (!isset($_POST['email']) || !preg_match('~^[_0-9a-z\-\.]+@[_0-9a-z\-\.]+\.[_0-9a-z\-\.]+$~i',$_POST['email'])) {
as you said, the validation regexp was incorrect, sorry :(
Logged

We don't need a reason to help people

chad

  • Guest
Re: Add a contact field to the form...
« Reply #4 on: January 04, 2006, 11:01:54 AM »

I have been trying to do this on my own and I realized you had a forum and I found exactly what I needed! This helped a lot, but I am still having trouble with the email validation. I replaced the validation code as you advised above and It still states that i have not entered an email address.
Logged

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 222
    • View Profile
    • PHP Simplicity
Re: Add a contact field to the form...
« Reply #5 on: January 18, 2006, 08:09:44 AM »

I am not sure why it's not working for you, but it should!
anyway, you could replace the validation with a simple one like:
Code: [Select]
if (!isset($_POST['email']) || trim($_POST['email']) == '') {
Logged

We don't need a reason to help people

justin

  • Guest
Re: Add a contact field to the form...
« Reply #6 on: April 02, 2006, 12:36:06 PM »

hey i have did it to but the results ar

http://www.server255.byethost9.com/uper/upload.php

not good  can you help me :D
Logged

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 222
    • View Profile
    • PHP Simplicity
Re: Add a contact field to the form...
« Reply #7 on: April 03, 2006, 11:36:50 AM »

you put <input type="text" name="email" /> in the wrong place, man :)

open functions.php and look for:
Code: [Select]
//start the loop ..
   for ($i = 0; $i < $num_files; $i++) {
      $form .= '
            <input type="file" name="SFUfile[]" size="20" '.$disabled.'/><br />';
   }

and then after it add:
Code: [Select]
$form.= '<br />Email: <input type="text" name="email" /><br />';
if you tried this and you are still having trouble, you could email me the functions.php file and I will modify it for you :)
« Last Edit: April 04, 2006, 06:37:23 PM by Saleh »
Logged

We don't need a reason to help people

justin

  • Newbie
  • *
  • Offline Offline
  • Posts: 2
    • View Profile
Re: Add a contact field to the form...
« Reply #8 on: April 04, 2006, 03:14:52 AM »

no it dont works it was the same that i did before  :( :(

i send you a personel message with in zip format my funtion.php


grtzz justin
Logged

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 222
    • View Profile
    • PHP Simplicity
Re: Add a contact field to the form...
« Reply #9 on: April 04, 2006, 06:37:12 PM »

oppss!
my bad! I found where the error is! it shouldn't be echo!
so instead change:
Code: [Select]
echo '<input type="text" name="email" /><br />';to:
Code: [Select]
$form.= '<br />Email: <input type="text" name="email" /><br />';
I tried this and it works fine :)
the problem that I forgot that echoing was the last part :(
Logged

We don't need a reason to help people
 

+ Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.
Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
Are you a bot/spammer?: