Ok..so i finally got the thing to validate and such, but now it takes away my ability to import the image to the directory..
not sure where the problem is because i never changed anything with that at all
here is my current code minus the db info
<?php
$post = isset($_GET['post'])?$_GET['post']:"";
if ($post == "yes") {
$UPLOADED_PHOTO = $_FILES['NEW_PHOTO']['name'];
$fname = $_POST['fname'];
$lname= $_POST['lname'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$attending = $_POST['attending'];
$email = $_POST['email'];
$error_msg=array();
if ($fname == ''){
$error_msg[]="Please enter your First name";
}
if(!preg_match('/^\b[a-zA-Z]+\b$/', $fname)){
$error_msg[]="First Name can only contain letters";
}
if ($lname == ''){
$error_msg[]="Please enter your last name";
}
if(!preg_match('/^\b[a-zA-Z]+\b$/', $lname)){
$error_msg[]="Last Name can only contain letters";
}
if ($address == ''){
$error_msg[]="Please enter your address";
}
if(!preg_match('/^[a-z0-9 ]*$/i', $address)){
$error_msg[]="Address can only contain numbers, letters and spaces";
}
if ($city == ''){
$error_msg[]="Please enter your city";
}
if (!preg_match('/^\b[a-zA-Z ]+\b$/', $city)){
$error_msg[]="City can only contain letters";
}
if ($state == ''){
$error_msg[]="Please enter your state";
}
if (strlen($state)<>2){
$error_msg[]="State can only contain 2 letters; use state abbreviation";
}
if (!preg_match("/^\b[a-zA-Z]+\b$/", $state)){
$error_msg[]="State can only contain letters";
}
if ($zip == ''){
$error_msg[]="Please enter your zip code";
}
if (strlen($zip)<>5){
$error_msg[]="Zip code can only contain 5 digits";
}
if(!is_numeric($zip)){
$error_msg[]="Zip code must contain only numbers";
}
if ($phone == ''){
$error_msg[]="Please enter your phone number";
}
if (strlen($phone)<>10){
$error_msg[]="Phone number can only contain 10 digits";
}
if(!is_numeric($phone)){
$error_msg[]="Phone number must contain only numbers";
}
if ($attending == ''){
$error_msg[]="Please enter if you plan to attend";
}
if ($email == ''){
$error_msg[]="Please enter your e-mail address";
}
if ($error_msg){
$display_errors = "
<table background='http://ufhl.theufhl.com/images/images/signupbk1.gif' width='640' height='560'>
<td valign='top' align='center'>
<table border='0' width='600' cellspacing='0' cellpadding='0'>
<tr><td height='66'></td></tr>
<TR>
<td width='25' height='30'></td>
<TD class=table_header>
<h3>There were errors in your submission.</h3>
<p>Please review the following errors, press the Back button on your browser, and make corrections before re-submitting.</p>
<ul style=color:red>\n";
foreach ($error_msg as $err){
$display_errors .= "<li>".$err."</li>\n";
}
$display_errors .= "</ul>\n
<p class=header align=center>GO <a href='javascript:history.go(-1)'><u>BACK</u></a> AND TRY AGAIN.</p>
</td></tr></td>
</table></table>";
}
if (!$error_msg){
$sql = "INSERT INTO robert (
id,fname,lname,address,city,state,zip,phone,attending,email,NEW_PHOTO $addl_insert_crit ) VALUES ( '$id',
'$fname','$lname','$address','$city','$state','$zip','$phone','$attending','$email','$UPLOADED_PHOTO' $addl_insert_values )";
if ($sql_debug_mode==1) { echo "<BR>SQL: $sql<BR>"; }
$result = mysql_query($sql,db());
echo "<table background='http://ufhl.theufhl.com/images/images/signupbk1.gif' width='640' height='560'>
<td valign='top' align='center'>
<table border='0' width='600' cellspacing='0' cellpadding='0'>
<tr><td height='66'></td></tr>
<TR>
<td width='25' height='30'></td>
<TD class=table_header>Thank you <font color='red'>$fname $lname </font>for completing the online RSVP form for the company's Christmas party. <br><br> Below you will find the details of the form you submitted. You will also be sent an e-mail with the information you provided and details of the Christmas party.
<br><br>
<b>Name:</b> $fname $lname<br>
<b>Address:</b> $address<br>
<b>City:</b> $city<br>
<b>State:</b> $state <b>Zip Code:</b> $zip<br><br>
<b>Phone:</b> $phone<br><br>
<b>Is Attending:</b> $attending<br><br>
<b>Photo:</b><br>";
if($_FILES["NEW_PHOTO"]["name"] != ""){
echo "
<img src='http://www.theufhl.com/images/news/thumb/". $_FILES["NEW_PHOTO"]["name"] ."'><br>
<a href='http://www.theufhl.com/images/news/". $_FILES["NEW_PHOTO"]["name"] ."'>". $_FILES["NEW_PHOTO"]["name"] ."</a>";
} else {
echo "
No Image Submitted";
}
echo "
</td></tr></td></table></table>";
$to = "webmaster@theufhl.com";
$subject = "XMAS RSVP for ($fname $lname)";
$body = "This is a Message to let you know that $fname $lname has completed the online RSVP company Christmas form.
//Text goes here to send the webmaster or desired person an e-mail
";
if (mail($to, $subject, $body)) {
}
$to1 = "$email";
$subject1 = "Jeppson Enterprise Christmas Party";
$body1 = "Hi $fname,
//text goes here for sending in email
Below you will find details of what you submitted
Name: $fname $lname
Address: $address
City: $city
State: $state Zip Code:$zip
Phone: $phone
Is Attending: $attending
Photo: http://www.theufhl.com/images/news/". $_FILES["NEW_PHOTO"]["name"] ."
";
if (mail($to1, $subject1, $body1)) {
}
}
echo $display_errors;
}
if (!$post) {
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?proc=New&post=yes" enctype="multipart/form-data">
<center>
<body topmargin='0' leftmargin='0' rightmargin='0' bottommargin='0'>
<div align='center'>
<table background='http://ufhl.theufhl.com/images/images/signupbk1.gif' width='640' height='560'>
<tr>
<td valign='top' align='center'>
<table border='0' width='340' cellspacing='0' cellpadding='0'>
<tr><td height='66'></td></tr>
<tr><td></td></tr>
<tr>
<td width='25' height='30'></td>
<td></td>
<td class='table_text' colspan='2'>
<input class='table_text' type='hidden' name='id'>
</td>
</tr>
<tr>
<td width='25' height='30'></td>
<td bgcolor='#dfdfdf' class='table_header'>First Name:</td>
<td bgcolor='#dfdfdf' class='table_text' colspan='2'>
<input class='table_text' type='text' name='fname'>
</td>
</tr>
<tr>
<td width='25' height='30'></td>
<td class='table_header'>Last Name:</td>
<td class='table_text' colspan='2'>
<input class='table_text' type='text' name='lname'>
</td>
</tr>
<tr>
<td width='25' height='30'></td>
<td class='table_header' bgcolor='#dfdfdf'>Address:</td>
<td class='table_text' bgcolor='#dfdfdf'>
<input class='table_text' type='text' name='address'>
</td>
</tr>
<tr>
<td width='25' height='30'></td>
<td class='table_header'>City:</td>
<td class='table_text'>
<input class='table_text' type='text' name='city'>
</td>
</tr>
<tr>
<td width='25' height='30'></td>
<td class='table_header' bgcolor='#dfdfdf'>State:</td>
<td class='table_text' bgcolor='#dfdfdf'>
<input class='table_text' type='text' name='state'>
</td>
</tr>
<tr>
<td width='25' height='30'></td>
<td class='table_header'>Zip Code:</td>
<td class='table_text'>
<input class='table_text' type='text' name='zip'>
</td>
</tr>
<tr>
<td width='25' height='30'></td>
<td class='table_header' bgcolor='#dfdfdf'>Phone:</td>
<td class='table_text' bgcolor='#dfdfdf'>
<input class='table_text' type='text' name='phone'>
</td>
</tr>
<tr>
<td width='25' height='30'></td>
<td class='table_header'>Attending:</td>
<td class='table_text'>
<select name='attending' class='table_text' style='width:78%'>
<option value=' '></option>
<option value='Yes'>Yes</option>
<option value='No'>No</option>
</select>
</td>
</tr>
<tr>
<td width='25' height='30'></td>
<td class='table_header' bgcolor='#dfdfdf'>E-Mail:</td>
<td class='table_text' bgcolor='#dfdfdf'>
<input class='table_text' type='text' name='email'>
</td>
</tr>
<tr>
<td width='25' height='30'></td>
<td class='table_header'>PHOTO:</td>
<td class='table_text'>
<input type='file' name='NEW_PHOTO' class='table_text'>
</td>
</tr>
<TR>
<TD>
</TD>
<TD>
</TD>
<TD>
<INPUT TYPE="SUBMIT" VALUE="Register" NAME="submit">
<INPUT TYPE="RESET" VALUE="Reset" NAME="reset">
</TD>
</TR>
</TABLE>
</CENTER>
<BR>
</FORM>
<?php
} //END if post=""
$uploaddir = "./images/news/";
$uploadthumb = "./images/news/thumb/";
include('./includes/SimpleImage.php');
include('./includes/function.php');
$uploadfile = $uploaddir . basename($_FILES['NEW_PHOTO']['name']);
$uploadthumbfile = $uploadthumb . basename($_FILES['NEW_PHOTO']['name']);
if (move_uploaded_file($_FILES['NEW_PHOTO']['tmp_name'], $uploadfile)) {
$image = new SimpleImage();
$image->load($uploadfile);
$image->resize(480,400);
$image->save($uploadfile);
$UPLOADED_PHOTO = basename($_FILES['NEW_PHOTO']['name']);
$thumb = new SimpleImage();
$thumb->load($uploadfile);
$thumb->resize(110,75);
$thumb->save($uploadthumbfile);
}else{
$UPLOADED_PHOTO = $_POST['PHOTO'];
}
?>