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. 
).
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:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
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’s ‘Back’ 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’s ‘Back’ 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’s ‘Back’ 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’s ‘Back’ button and try again<br /><br />';
exit;
}
/*End Edit*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Here's the data from the functions file:
<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:
$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.