Ok, so I used to be very good in HTML, PHP, and JS, but it's been a long time since I used it. been trying to make just a simple order form for a friends business. Though I wanted it to do server side validation and emailing... But it doesn't do anything.... on submit I get no errors when there are and with no errors I get no email to my inbox..
What it is supposed to do is gather what pictures they checked and their sizes as well as a person info and email it to an email address. Though I want it to check for required areas and correct input (like email has @ and a .com in it, zip is digits only, etc... But yeah my code shows the order form and looks nice, but does nothing....
<?php
require_once "formvalidator.php";
$error_hash = 'no';
$show_form = true;
class MyValidator extends CustomValidator
{
function DoValidate(&$formars,&$error_hash)
{
if(stristr($formars['comments'],'http://'))
{
$error_hash['comments']="No URLs allowed in comments";
return false;
}
return true;
}
}
if (isset($_REQUEST['Submit']))
{
$validator = new FormValidator();
$validator->addValidation("email", "email", "<B>Email address is invalid.</B>");
$validator->addValidation("first", "req", "<B>Please provide your first name for invoice.</B>");
$validator->addValidation("addr", "req", "<B>Please provide your address for invoice.</B>");
$validator->addValidation("city", "req", "<B>Please provide your city name for invoice.</B>");
$validator->addValidation("zip", "req", "<B>Please provide your zipcode for invoice.</B>");
$validator->addValidation("last", "req", "<B>Please provide your last name for invoice.</B>");
$validator->addValidation("zip", "num", "<B>Numbers only in Zipcode.</B>");
$validator->addValidation("phone", "num", "<B>Numbers only in phone number.</B>");
if ($validator->ValidateForm()) {
$show_form = false;
} else {
echo "<center><font color='#CC0000'><B>Validation Errors:</B></font></center>";
$error_hash = $validator->GetErrors();
foreach ($error_hash as $inpname => $inp_err) {
echo "<center><p>$inpname : $inp_err</p></center>\n";
$show_form = true;
}
}
if ($show_form === false){
// Grab the form vars
$Pic = $_REQUEST['pic[]'] ;
$Size = $_REQUEST['size[]'] ;
$Email = $_REQUEST['email'];
$Name = $_REQUEST['first'. 'last'];
$Addr = $_REQUEST['addr'];
$City = $_REQUEST['city'];
$State = $_REQUEST['state'];
$Zip = $_REQUEST['zip'];
$comments = $_REQUEST['comments'] ;
if(empty($pic))
{
echo "<center><font color='#CC0000'><B>Please Select a picture.</B></font></center>";
}
else
{
$r = count($pic);
for($i=0; $i < $r; $i++)
{
echo "picture(s) requested $i was: " . $pic[$i] . "\r\n";
}
}
if(empty($size))
{
echo "<center><font color='#CC0000'><B>Please Select a picture size.</B></font></center>";
}
else
{
$r = count($size);
for($i=0; $i < $r; $i++)
{
echo "Sizes(s) requested $i was: " . $size[$i] . "\r\n";
}
}
//message body
$mail_body .= "$Pic"."\r\n";
$mail_body .= "$Size"."\r\n";
$mail_body .= "$Email"."\r\n";
$mail_body .= "$Name"."\r\n";
$mail_body .= "$Addr"."\r\n";
$mail_body .= "$City,". " $State". " $Zip"."\r\n";
$mail_body .= "$Comments"."\r\n";
//sending to
$recipient = "hakarune@gmail.com";
$subject = "Order Form";
//Headerfields
$header = "From: " . $Email . " <" . $Email . ">\r\n";
//mail command
mail($recipient, $subject, $mail_body, $header);
}
echo "<div style='width:400px; margin:0 auto; border:1px solid #1e1e1e'>Your order has been sent successfully. <br>An Invoice will be either emailed or mailed to you, thank you for your order.<br>You will be redirected to the home page in a few moments...</div>";
//page redirect to home
echo "<meta http-equiv=\"refresh\" content=\"4;url=";
echo "http://lmtl-linux/credit\" />";
}
if (true == $show_form) {
?>
<form name="ordering" action="" method="GET" enctype="text/plain">
<img src="1.jpg" />
<input type="checkbox" name="pic[]" value="1">
<br />
<select name="Type" size="1" name="size[]" Value="1">
<option value="">Select Type</option>
<option value="Original">Original $Price</option>
<option value="Print Small">300x500 Print $Price</option>
<option value="Print Medium">800x600 Print $Price</option>
<option value="Print Large">1200x1280 Print $Price</option>
<option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<img src="2.jpg" />
<input type="checkbox" name="pic[]" value="2">
<br />
<select name="Type" size="1" name="size[]" Value="2">
<option value="">Select Type</option>
<option value="Original">Original $Price</option>
<option value="Print Small">300x500 Print $Price</option>
<option value="Print Medium">800x600 Print $Price</option>
<option value="Print Large">1200x1280 Print $Price</option>
<option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<img src="3.jpg" />
<input type="checkbox" name="size[]" Value="3">
<br />
<select name="Type" size="1" name="size3">
<option value="">Select Type</option>
<option value="Original">Original $Price</option>
<option value="Print Small">300x500 Print $Price</option>
<option value="Print Medium">800x600 Print $Price</option>
<option value="Print Large">1200x1280 Print $Price</option>
<option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<img src="4.jpg" />
<input type="checkbox" name="pic[]" value="4">
<br />
<select name="Type" size="1" name="size[]" Value="4">
<option value="">Select Type</option>
<option value="Original">Original $Price</option>
<option value="Print Small">300x500 Print $Price</option>
<option value="Print Medium">800x600 Print $Price</option>
<option value="Print Large">1200x1280 Print $Price</option>
<option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<img src="5.jpg" />
<input type="checkbox" name="pic[]" value="5">
<br />
<select name="Type" size="1" name="size[]" Value="5">
<option value="">Select Type</option>
<option value="Original">Original $Price</option>
<option value="Print Small">300x500 Print $Price</option>
<option value="Print Medium">800x600 Print $Price</option>
<option value="Print Large">1200x1280 Print $Price</option>
<option value="Print XLarge">1282x1400 Print $Price</option>
</select>
<br />
<br />
<br />
Information For Invoice: <font color="red">(Required Info = *)</font>
<br />
<input type="text" name="first" Value="First Name" size="25" onfocus="value=''"><font
color="red">*</font>
<input type="text" name="last" Value="Last Name" size="25" onfocus="value=''"><font
color="red">*</font>
<br />
<input type="text" name="phone" Value="Phone Number" size="25" onfocus="value=''">
<br />
<input type="text" name="email" Value="E-mail" size="30" onfocus="value=''">
<br />
<input type="text" name="addr" Value="Street Address" size="50" onfocus="value=''"><font
color="red">*</font>
<br />
<input type="text" name="city" Value="city" size="30" onfocus="value=''"><font
color="red">*</font>
<br />
<select name="state" size="1">
<option value="">Select State</option>
<option value="AK">AK</option>
<option value="AL">AL</option>
<option value="AR">AR</option>
<option value="AZ">AZ</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DC">DC</option>
<option value="DE">DE</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="HI">HI</option>
<option value="IA">IA</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="MA">MA</option>
<option value="MD">MD</option>
<option value="ME">ME</option>
<option value="MI">MI</option>
<option value="MN">MN</option>
<option value="MO">MO</option>
<option value="MS">MS</option>
<option value="MT">MT</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="NE">NE</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NV">NV</option>
<option value="NY">NY</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PA">PA</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SD</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="VA">VA</option>
<option value="VT">VT</option>
<option value="WA">WA</option>
<option value="WI">WI</option>
<option value="WV">WV</option>
<option value="WY">WY</option>
</select>
<br />
<input type="text" name="zip" Value="Zipcode" size="5" onfocus="value=''"><font
color="red">*</font>
<br />
<textarea name="comments" rows="15" cols="40" value="comments" onfocus="value=''">
</textarea>
<br />
<input type=button value="Submit">
<input type="reset" value="Clear Form">
</form>
<?php
}//true == $show_form
?>