PHP Simplicity Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Guest posting is allowed. Again!

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

0 Members and 2 Guests are viewing this topic.

eakucera00

  • Guest
Add a contact field to the form...
« on: August 16, 2005, 12:41:04 am »
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: 212
    • View Profile
    • WWW
Re: Add a contact field to the form...
« Reply #1 on: August 19, 2005, 10: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: (THIS PART OF CODE WAS UPDATED.. LOOK DOWN)
Code: [Select]
   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;
   }

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: April 04, 2006, 10:37:36 pm 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, 04: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: 212
    • View Profile
    • WWW
Re: Add a contact field to the form...
« Reply #3 on: August 22, 2005, 07: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, 04:01:54 pm »
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: 212
    • View Profile
    • WWW
Re: Add a contact field to the form...
« Reply #5 on: January 18, 2006, 01:09:44 pm »
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, 04: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: 212
    • View Profile
    • WWW
Re: Add a contact field to the form...
« Reply #7 on: April 03, 2006, 03:36:50 pm »
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, 10: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, 07: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: 212
    • View Profile
    • WWW
Re: Add a contact field to the form...
« Reply #9 on: April 04, 2006, 10: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.
After submitting your post you will be directed to the regular post page to verify your post (required for all guests).
Name: Email: