crusherboy Posted May 17, 2007 Share Posted May 17, 2007 Hello, I downloaded this script http://www.thewebhelp.com/php/php_contact_form_with_image_validation/ everything work fine, but i need to add "checkbox" now, do you guys have any idea what i need to change or modify? I contact several the website from where i downloaded the script, but no answer. I am really new with PHP, so please help! Example, <input name="subject" type="text" id="subject" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;" value="<?php echo $_GET['subject'];?>"/> I though i was able to change type="text" to type="checkbox" and this will do it, but it doesnt work. Quote Link to comment https://forums.phpfreaks.com/topic/51910-validation-image-form-issue-while-adding-a-checkbox-in-the-code/ Share on other sites More sharing options...
corbin Posted May 17, 2007 Share Posted May 17, 2007 Look up a HTML tutorial on checkboxes, and find a PHP tutorial on the POST/GET arrays.... Quote Link to comment https://forums.phpfreaks.com/topic/51910-validation-image-form-issue-while-adding-a-checkbox-in-the-code/#findComment-255920 Share on other sites More sharing options...
crusherboy Posted May 17, 2007 Author Share Posted May 17, 2007 I already did that, I have my checkboxes in the code etc... Just when I click on the submit, i dont receive anything in my email about this checkboxes field, i can see all the data from my input"Text" but nothing from "checkboxes" :-\ Quote Link to comment https://forums.phpfreaks.com/topic/51910-validation-image-form-issue-while-adding-a-checkbox-in-the-code/#findComment-255938 Share on other sites More sharing options...
AndyB Posted May 18, 2007 Share Posted May 18, 2007 OK, let's see the form processing script (just the php parts, we don't need a load of html) Quote Link to comment https://forums.phpfreaks.com/topic/51910-validation-image-form-issue-while-adding-a-checkbox-in-the-code/#findComment-256028 Share on other sites More sharing options...
crusherboy Posted May 18, 2007 Author Share Posted May 18, 2007 Here is my index.php <head> <script type="text/JavaScript"> <!-- function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='are') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'are') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } //--> </script> </head> <body> <form action="orderform/mailer.php" method="post" name="form1" id="form1" style="margin:0px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px; width:300px;" onsubmit="MM_validateForm('from','','RisEmail','subject','','are','verif_box','','are','message','','are','Firstname','','are','Address','','are','City','','are','Postal','','are','Tel','','are','Name','','are','Quantity','','are','Card','','are','Domains','','are','Domains','','are','Domains','','are');return document.MM_returnValue"> <p align="left"><font color="#FF0000">*</font> Required Field </p> <table width="700" border="1" cellspacing="3" cellpadding="0" bordercolor="#ECE9E9"> <tr> <td colspan="2" bgcolor="#F1F1F1"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b>Client information <br> </b></font></div> </td> <td valign="top" width="442" bgcolor="#F1F1F1"> <div class="centerdiv"><b><font face="Arial, Helvetica, sans-serif">ORDER SHEET<br> </font></b></div> </td> </tr> <tr> <td width="86"> <p><font face="Arial, Helvetica, sans-serif" size="2">Client</font></p> </td> <td width="152"> <font face="Arial, Helvetica, sans-serif" size="2"> <input name="Firstname" type="text" id="Firstname" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:19px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['Firstname'];?>"/> </font></td> <td valign="top" width="442" bgcolor="#F1F1F1"> <div class="centerdiv"><font face="Arial, Helvetica, sans-serif"><i>Condolence Cards<br> </i></font></div> </td> </tr> <tr> <td width="86"><font face="Arial, Helvetica, sans-serif" size="2">Address<br> </font></td> <td width="152"> <font face="Arial, Helvetica, sans-serif" size="2"> <input name="Address" type="text" id="Address" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:19px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['Address'];?>"/> </font></td> <td valign="top" rowspan="14" width="442"> <div class="centerdiv"><img src="http://www.dupuisprinting.ca/images/photo-cardnumber.jpg" width="180" height="340"><br> </div> <div align="center"> <table width="330" border="1" cellspacing="3" cellpadding="0" align="center" bordercolor="#ECE9E9"> <tr> <td colspan="2" bgcolor="#F1F1F1"> <div align="center"><font face="Arial, Helvetica, sans-serif"><b>Price list<br> </b></font></div> </td> </tr> <tr> <td width="205"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b><i>Black & White </i></b></font></div> </td> <td width="205"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b><i>Color</i></b></font></div> </td> </tr> <tr> <td width="205"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">25 - $50.00</font></div> </td> <td width="205"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">25 - $80.00</font></div> </td> </tr> <tr> <td width="205" height="21"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">50 - $70.00</font></div> </td> <td width="205" height="21"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">50 - $105.00</font></div> </td> </tr> <tr> <td width="205"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">75 - $85.00</font></div> </td> <td width="205"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">75 - $125.00</font></div> </td> </tr> <tr> <td width="205"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">100 - $95.00</font></div> </td> <td width="205"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2">100 - $140.00</font></div> </td> </tr> <tr> <td width="205" bgcolor="#F1F1F1"> <div align="center"><font size="2" face="Arial, Helvetica, sans-serif">50 cent additional card<br> </font></div> </td> <td width="205" bgcolor="#F1F1F1"> <div align="center"><font size="2" face="Arial, Helvetica, sans-serif">75 cent additional card<br> </font></div> </td> </tr> <tr> <td colspan="2"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b><i>Prices include laminated cards<br> </i></b></font></div> </td> </tr> </table> </div> </td> </tr> <tr> <td width="86"><font face="Arial, Helvetica, sans-serif" size="2">City<br> </font></td> <td width="152"> <font face="Arial, Helvetica, sans-serif" size="2"> <input name="City" type="text" id="City" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:19px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['City'];?>"/> </font></td> </tr> <tr> <td width="86"><font face="Arial, Helvetica, sans-serif" size="2">Postal Code </font></td> <td width="152"> <font face="Arial, Helvetica, sans-serif" size="2"> <input name="Postal" type="text" id="Postal" style="padding:2px; border:1px solid #CCCCCC; width:60px; height:19px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['Postal'];?>" maxlength="7" size="7"/> <font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#FF0000"> <br> ie: E1A 8A8</font></font></td> </tr> <tr> <td width="86"><font face="Arial, Helvetica, sans-serif" size="2">Tel</font></td> <td width="152"> <font face="Arial, Helvetica, sans-serif" size="2"> <input name="Tel" type="text" id="Tel" style="padding:2px; border:1px solid #CCCCCC; width:90px; height:19px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['Tel'];?>" maxlength="12" size="12"/> <br> <font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FF0000"> ie: 506 123 4567</font></font></td> </tr> <tr> <td colspan="2" bgcolor="#F1F1F1" height="18"> <div align="center"><font face="Arial, Helvetica, sans-serif" size="2"><b>Information on the deceast<br> </b></font></div> </td> </tr> <tr> <td width="86"><font face="Arial, Helvetica, sans-serif" size="2">Name<br> </font></td> <td width="152"> <font face="Arial, Helvetica, sans-serif" size="2"> <input name="Name" type="text" id="Name" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:19px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['Name'];?>"/> </font></td> </tr> <tr> <td width="86"><font face="Arial, Helvetica, sans-serif" size="2">Quantity</font><br> <br> </td> <td width="152"><font face="Arial, Helvetica, sans-serif" size="2"> <input name="Quantity" type="text" id="Quantity" style="padding:2px; border:1px solid #CCCCCC; width:50px; height:19px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['Quantity'];?>"/> </font></td> </tr> <tr> <td width="86"><font face="Arial, Helvetica, sans-serif" size="2">Card # <br> </font></td> <td width="152"> <font face="Arial, Helvetica, sans-serif" size="2"> <input name="Card" type="text" id="Card" style="padding:2px; border:1px solid #CCCCCC; width:50px; height:19px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['Card'];?>"/> <font size="1"><a href="javascript:open1()"><br> see the cards</a></font></font></td> </tr> <tr> <td width="86"><font face="Arial, Helvetica, sans-serif" size="2">Prayer #<br> </font></td> <td width="152"> <font face="Arial, Helvetica, sans-serif" size="2"> <input name="Prayer" type="text" id="Prayer" style="padding:2px; border:1px solid #CCCCCC; width:50px; height:19px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['Prayer'];?>"/> <font size="1"><a href="javascript:open2()"><br> see the prayers</a></font></font></td> </tr> <tr> <td width="86"><font face="Arial, Helvetica, sans-serif" size="2">Text<br> </font></td> <td width="152"><font face="Arial, Helvetica, sans-serif" size="2"> <input name="English" type="checkbox" id="English" style="padding:1px; border:1px solid #CCCCCC; width:15px; height:15px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['English'];?>"/> english <font size="1"><a href="javascript:open3()"><br> view sample</a></font><br> <input name="Francais" type="checkbox" id="Francais" style="padding:1px; border:1px solid #CCCCCC; width:15px; height:15px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['Francais'];?>"/> français <font size="1"><a href="javascript:open3()"><br> view sample</a></font></font></td> </tr> <tr> <td width="86"><font face="Arial, Helvetica, sans-serif" size="2">Photo supplied<br> <b><font size="1" color="#FF0000">ps, if photo is scanned, please scan at 400DPI</font></b></font></td> <td width="152"> <font face="Arial, Helvetica, sans-serif" size="2"> <input type="checkbox" name="scanoriginal" value="checkbox"> orignal<br> <input type="checkbox" name="scanemail" value="checkbox"> email<br> <input type="checkbox" name="scancd" value="checkbox"> cd </font></td> </tr> <tr> <td width="86"><font face="Arial, Helvetica, sans-serif" size="2">Comments</font></td> <td width="152"><font face="Arial, Helvetica, sans-serif" size="2"> <textarea name="message" cols="6" rows="5" id="message" style="padding:2px; border:1px solid #CCCCCC; width:300px; height:100px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;"><?php echo $_GET['message'];?></textarea> </font></td> </tr> <tr> <td colspan="2" height="39" bgcolor="#F1F1F1"> <font color="#FF0000">*</font> <font face="Arial, Helvetica, sans-serif" size="2">Type verification image:</font><br /> <input name="verif_box" type="text" id="verif_box" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:19px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;"/> <img src="orderform/verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="absbottom" /><br /> <br /> <!-- if the variable "wrong_code" is sent from previous page then display the error field --> <?php if(isset($_GET['wrong_code'])){?> <div style="border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding-left:6px;width:295px;"><font face="Arial, Helvetica, sans-serif" size="2">Wrong verification code</font></div> <br /> <br /> <?php ;}?> </td> </tr> <tr> <td colspan="2" height="39" bgcolor="#F1F1F1"> <div align="center"> <input name="Submit" type="submit" style="margin-top:10px; display:block; border:1px solid #000000; width:100px; height:20px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; padding-left:2px; padding-right:2px; padding-top:0px; padding-bottom:2px; line-height:14px; background-color:#EFEFEF;" value="Send Message"/> </div> </td> </tr> </table> <p> </p> </form> </body> </html> Here is my mailer.php <?php // load the variables form address bar $subject = $_REQUEST["subject"]; $message = $_POST["message"]; $from = $_REQUEST["from"]; $verif_box = $_REQUEST["verif_box"]; $Firstname = $_POST["Firstname"]; $Address = $_POST["Address"]; $City = $_POST["City"]; $Postal = $_POST["Postal"]; $Tel = $_POST["Tel"]; $Name = $_POST["Name"]; $Quantity = $_POST["Quantity"]; $Card = $_POST["Card"]; $Prayer = $_POST["Prayer"]; $English = $_POST["English"]; $Francais = $_POST["Francais"]; // remove the backslashes that normally appears when entering " or ' $message = stripslashes($message); $subject = stripslashes($subject); $from = stripslashes($from); $Firstname = stripslashes($Firstname); $Address = stripslashes($Address); $City = stripslashes($City); $Postal = stripslashes($Postal); $Tel = stripslashes($Tel); $Name = stripslashes($Name); $Quantity = stripslashes($Quantity); $Card = stripslashes($Card); $Prayer = stripslashes($Prayer); $English = stripslashes($English); $Francais = $_POST["Francais"]; // check to see if verificaton code was correct if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ // if verification code was correct send the message and show this page mail("info@idweb.ca", 'IDWEB Condolence Online Form: '.$subject, $_SERVER['REMOTE_ADDR']."\n\n".$Firstname."\n\n".$Domains."\n\n".$message, "From: $from"); // delete the cookie so it cannot sent again by refreshing this page setcookie('tntcon',''); } else { // if verification code was incorrect then return to contact page and show error header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true"); exit; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>E-Mail Sent</title> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 12px; } --> </style></head> <body> <p align="center"><img src="http://www.idweb.ca/images/Untitled-1.jpg" width="126" height="66"><img src="http://www.idweb.ca/images/Untitled-2.jpg" width="73" height="65"><br> <img src="http://www.idweb.ca/images/Untitled-3.jpg" width="126" height="43"><img src="http://www.idweb.ca/images/Untitled-4.jpg" width="73" height="43"> </p> <p align="center"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#336699">Your Request Has Been Processed!<br> Thank you.</font></b></p> <p align="center"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#336699">[<a href="/">back</a>]</font></b></p> <p align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#999999"> @ Dupuis Printing</font></p> </body> </html> So what i did basically, i added this code in my index.php <input name="English" type="checkbox" id="English" style="padding:1px; border:1px solid #CCCCCC; width:15px; height:15px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['English'];?>"/> But when I add this code, the verification ask for it like it should, but when i checkmark the box or not, it always ask me or telling to fillup this place, but the checkmark is already there... Quote Link to comment https://forums.phpfreaks.com/topic/51910-validation-image-form-issue-while-adding-a-checkbox-in-the-code/#findComment-256385 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.