PHP Simplicity Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

I am not always around so I might be late on replying.

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

0 Members and 1 Guest are viewing this topic.

Bruce

  • Guest
Re: Add a contact field to the form...
« Reply #20 on: May 12, 2010, 12:37:17 PM »

I have been changing this around every way mentioned here and it has me lost I do not see the echo '<input type="text" name="email" /><br />'; anywhere to replace with $form.= '<br />Email: <input type="text" name="email" /><br />'; and I am lost. help would be appreciated. Bruce
Logged

bruce

  • Guest
Re: Add a contact field to the form...
« Reply #21 on: May 12, 2010, 05:02:21 PM »

the file is uploaded but i do not get the email name on the email I receive just the file name.
Logged

Hawk

  • Newbie
  • *
  • Offline Offline
  • Posts: 9
    • View Profile
Re: Add a contact field to the form...
« Reply #22 on: November 15, 2010, 12:30:21 PM »

Hi Folks!

I just found this great script and I think it's going to be very useful for my website.

I have done some modification based on information in this thread but I'm having a small issue that I hope someone can help me with (I know just enough about php to be dangerous.  :D ).

I've added some extra form fields (4) and would like all of them to be required but so far have only been able to make the last one required (email).
I get the error about not filling in the other 3 fields, but the file does successfully upload, but the file won't upload without the email field filled in.
I would like to file to fail the upload if any of the 4 fields are left empty.

Here's the data from the upload file:
Code: [Select]
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
Edit by me from this thread  http://www.phpsimplicity.com/forum/index.php?PHPSESSID=ed6443166758aae822456829323725f1&topic=61.0 
for extra form fields for email
*/
/*New edit*/
  #if (!isset($_POST['email']) || !preg_match('^[a-z0-9._-]+@+[a-z0-9._-]+.+[a-z]{2,4}$',$_POST['email'])) {
      if (!isset($_POST['fname']) || !preg_match('~^[a-zA-Z.-s]+$~i',$_POST['fname']))
        echo '<p align="'.$txt['align'].'"><span style="color:#800000"><b>Oops! You forgot to enter your First Name!</b></span>
        <br />Click your browser&rsquo;s &lsquo;Back&rsquo; button and try again<br /><br />';

      if (!isset($_POST['lname']) || !preg_match('~^[a-zA-Z.-s]+$~i',$_POST['lname']))
        echo '<p align="'.$txt['align'].'"><span style="color:#800000"><b>Oops! You forgot to enter your Last Name!</b></span>
        <br />Click your browser&rsquo;s &lsquo;Back&rsquo; button and try again<br /><br />';

      if (!isset($_POST['uname']) || !preg_match('~^[_0-9a-zA-Z-.s]+$~i',$_POST['uname']))
        echo '<p align="'.$txt['align'].'"><span style="color:#800000"><b>Oops! You forgot to enter your Forum Username!</b></span>
        <br />Click your browser&rsquo;s &lsquo;Back&rsquo; button and try again<br /><br />';

      if (!isset($_POST['email']) || !preg_match('~^[_0-9a-z-.]+@[_0-9a-z-.]+.[_0-9a-z-.]+$~i',$_POST['email'])) {
      echo '<p align="'.$txt['align'].'"><span style="color:#800000"><b>Oops! You forgot to enter your email!</b></span>
      <br />Click your browser&rsquo;s &lsquo;Back&rsquo; button and try again<br /><br />';
     
      exit;
   }
/*End Edit*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Here's the data from the functions file:
Code: [Select]
<tr>
      <td>
            <form method="post" enctype="multipart/form-data" action="'.$action.'" onsubmit="return preValidate();"/>
            <input type="hidden" name="MAX_FILE_SIZE" value="'.SFU_MAXSIZE * 1024 .'" />';
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
Edit by me from this thread  http://www.phpsimplicity.com/forum/index.php?PHPSESSID=ed6443166758aae822456829323725f1&topic=61.0 
for extra form fields for email
*/
/*New edit-Add*/

$form.= '<p class="bld"><span class="grn">First Name:</span><input type="text" name="fname" size="50" /></p>';
$form.= '<p class="bld"><span class="grn">Last Name:</span> <input type="text" name="lname" size="50" /></p>';
$form.= '<p class="bld"><span class="grn">Forum Username:</span> <input type="text" name="uname" size="50" /></p>';
$form.= '<p class="bld"><span class="grn">Email Address:</span> <span class="ital lt-blu">(Required)</span><input type="text" name="email" size="55" /></p>
<p class="add bld grn">Add your files:</p>';
/*End edit*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//start the loop ..
   for ($i = 0; $i < $num_files; $i++) {
      $form .= '
            <p><input type="file" name="SFUfile[]" size="47" '.$disabled.'/></p>';
   }

//close form..
   $form .='</td>
   </tr>';

I've also set it up to include the above information in the email the script sends. This works fine.

From the upload file:
Code: [Select]
$email_message = $_POST['email'] . " " . $_POST['fname'] . " " . $_POST['lname'] . " " . $_POST['uname'];
if ($notify_admin == true)
      MailUploaded($email_message);

I'm sure it's something simple but after 2 days of trying anything I could think of, I'm not finding the right answer.  ???

Thanks for any help!  :)

I've even been able to add an animated progress image as discussed in this thread:  http://www.phpsimplicity.com/forum/index.php/topic,194.0.html.
Feel free to test it and see the image.  ;)
 
« Last Edit: November 23, 2010, 05:29:08 PM by Hawk »
Logged
Hawk

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 222
    • View Profile
    • PHP Simplicity
Re: Add a contact field to the form...
« Reply #23 on: November 18, 2010, 08:28:13 AM »

Note that you have had exit; only on the email checking part.
The code should be like:
Code: [Select]
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
Edit by me from this thread  http://www.phpsimplicity.com/forum/index.php?PHPSESSID=ed6443166758aae822456829323725f1&topic=61.0
for extra form fields for email
*/
/*New edit*/
  #if (!isset($_POST['email']) || !preg_match('^[a-z0-9._-]+@+[a-z0-9._-]+.+[a-z]{2,4}$',$_POST['email'])) {
      if (!isset($_POST['fname']) || !preg_match('~^[a-zA-Z.-s]+$~i',$_POST['fname']))
  {
        echo '<p align="'.$txt['align'].'"><span style="color:#800000"><b>Oops! You forgot to enter your First Name!</b></span>
        <br />Click your browser&rsquo;s &lsquo;Back&rsquo; button and try again<br /><br />';

exit;
  }

      if (!isset($_POST['lname']) || !preg_match('~^[a-zA-Z.-s]+$~i',$_POST['lname']))
  {
        echo '<p align="'.$txt['align'].'"><span style="color:#800000"><b>Oops! You forgot to enter your Last Name!</b></span>
        <br />Click your browser&rsquo;s &lsquo;Back&rsquo; button and try again<br /><br />';

exit;
  }

      if (!isset($_POST['uname']) || !preg_match('~^[_0-9a-zA-Z-.s]+$~i',$_POST['uname']))
  {
        echo '<p align="'.$txt['align'].'"><span style="color:#800000"><b>Oops! You forgot to enter your Forum Username!</b></span>
        <br />Click your browser&rsquo;s &lsquo;Back&rsquo; button and try again<br /><br />';

exit;
  }

      if (!isset($_POST['email']) || !preg_match('~^[_0-9a-z-.]+@[_0-9a-z-.]+.[_0-9a-z-.]+$~i',$_POST['email']))
  {
      echo '<p align="'.$txt['align'].'"><span style="color:#800000"><b>Oops! You forgot to enter your email!</b></span>
      <br />Click your browser&rsquo;s &lsquo;Back&rsquo; button and try again<br /><br />';
     
      exit;
      }
/*End Edit*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

And that's the first time I've seen SFU modified and integrated in a such a nice way! Kudos :D
Logged

We don't need a reason to help people

Hawk

  • Newbie
  • *
  • Offline Offline
  • Posts: 9
    • View Profile
Re: Add a contact field to the form...
« Reply #24 on: November 18, 2010, 04:15:47 PM »

That did the trick. I knew it was something simple I was overlooking.  :D

Thanks for your help, and thank you for the kind words - but most of all, thank you for the great script.  ;D
Logged
Hawk

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 222
    • View Profile
    • PHP Simplicity
Re: Add a contact field to the form...
« Reply #25 on: November 18, 2010, 06:15:09 PM »

You are most welcome :)
Logged

We don't need a reason to help people

Hawk

  • Newbie
  • *
  • Offline Offline
  • Posts: 9
    • View Profile
Re: Add a contact field to the form...
« Reply #26 on: November 21, 2010, 08:23:52 AM »

I hate to bother you again, but how would I go about adding a message box and getting the message included in the email?

I can get the text area to show, but any message entered into the text box isn't included in the email.

Here's a link to the current test page:  http://paphalophagus.com/test/upload-page.htm

functions:
Code: [Select]
$form.= '
<p class="cent">First Name:<br /> <input type="text" name="fname" size="50" /></p>';
    $form.= '
<p class="cent">Last Name:<br /> <input type="text" name="lname" size="50" /></p>';
    $form.= '
<p class="cent">Forum Username:<br /> <input type="text" name="uname" size="50" /></p>';
    $form.= '
<p class="cent">Email Address:<br /> <input type="text" name="email" size="50" /></p>';
    $form.= '
<p class="cent">Add a Message:<br /> <textarea type="textarea" rows="6" cols="50" name="message" /></textarea></p>
<p class="cent add">Add your files: <span class="ital dk-yellow">(at least 1 File Required)</span></p>';

upload:
Code: [Select]
if (!isset($_POST['fname']) || !preg_match('~^[a-zA-Z.-s]+$~i',$_POST['fname']))
        echo '<p align="'.$txt['align'].'">';

      if (!isset($_POST['lname']) || !preg_match('~^[a-zA-Z.-s]+$~i',$_POST['lname']))
        echo '<p align="'.$txt['align'].'">';

      if (!isset($_POST['uname']) || !preg_match('~^[_0-9a-zA-Z-.s]+$~i',$_POST['uname']))
        echo '<p align="'.$txt['align'].'">';

      if (!isset($_POST['email']) || !preg_match('~^[_0-9a-z-.]+@[_0-9a-z-.]+.[_0-9a-z-.]+$~i',$_POST['email']))
      echo '<p align="'.$txt['align'].'">';
     
      if (!isset($_POST['message']) || !preg_match('~^[_0-9a-zA-Z-.s]+$~i',$_POST['message']))
        echo '<p align="'.$txt['align'].'">';


Edit 1:
Never mind. I figured it out. I forgot to add it to this line in upload.php:

Code: [Select]
$email_message = $_POST['email'] . " " . $_POST['fname'] . " " . $_POST['lname'] . " " . $_POST['uname'] . " " . $_POST['message'];
« Last Edit: November 23, 2010, 04:15:21 PM by Hawk »
Logged
Hawk

Saleh

  • Administrator
  • Full Member
  • *****
  • Offline Offline
  • Posts: 222
    • View Profile
    • PHP Simplicity
Re: Add a contact field to the form...
« Reply #27 on: November 24, 2010, 11:43:13 AM »

Very well :)
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:
What is the answer to one plus one? (in numbers):