Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Emailer Redirect Not Working for Verification Error
    primarykey
    data
    text
    <p>Okay, I am a little confused because this code was working and for some reason has stopped. Not sure when it stopped working, but someone on this site created it for me and it was perfect when it worked. The person combined my mailer.php, redirect pages, and html code all in one awesome page. The successful page submitted works, but the incorrect verification code error spontaneously stopped working (?).</p> <p>Here is the code:</p> <pre><code> &lt;?php $state = 0; // 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("myemail@hotmail.com", 'Website Inquiry '.$subject, "\n\n".'Name: '.$name."\n\n".'Company: '.$company."\n\n".'Phone Number: '.$phone."\n\n".'Contact Me By: '.$ContactMethod."\n\n".'City: '.$city."\n\n".'I am Interested In: '.$InterestedIn."\n\n".'Comments: '.$comments."\n\n".$from."\n\n".$_SERVER['REMOTE_ADDR'], "From: $email"); // delete the cookie so it cannot sent again by refreshing this page setcookie('tntcon',''); $state = 2; } else if(isset($message) and $message!=""){ // if verification code was incorrect then return to contact page and show error $state = 1; } if ($state == 0) { ?&gt; &lt;form action="" method="post" name="form1" id="form1" onsubmit="MM_validateForm('email','','RisEmail','name','','R','verif_box','','R','comments','','R');return document.MM_returnValue"&gt; </code></pre> <h3>Contact Form</h3> <p>Please complete the form below to have someone from our sales team contact you</p> <pre><code> &lt;p&gt;&lt;strong&gt;Tell us what you're interested in:&lt;/strong&gt;&lt;/p&gt; &lt;dl&gt; &lt;dd&gt; &lt;input type="radio" name="InterestedIn" value="BIBS&lt;?php echo $_GET['InterestedIn'];?&gt;"&gt; Blow-In-Blanket System &lt;input type="radio" name="InterestedIn" value="Spray Foam&lt;?php echo $_GET['InterestedIn'];?&gt;"&gt; Soya Spray Foam &lt;input type="radio" name="InterestedIn" value="Attic Insulation&lt;?php echo $_GET['InterestedIn'];?&gt;"&gt; Attic Insulation &lt;input type="radio" name="InterestedIn" value="Not Sure&lt;?php echo $_GET['InterestedIn'];?&gt;" checked="checked"&gt; Not Sure&lt;/dd&gt; &lt;/dl&gt; &lt;p&gt;&lt;strong&gt;Enter additional comments* in the space provided below:&lt;/strong&gt;&lt;/p&gt; &lt;dl&gt; &lt;dd&gt;&lt;textarea name="comments" cols="50" rows="5" border="0" id="comments"&gt;&lt;?php echo $_GET['comments'];?&gt;&lt;/textarea&gt;&lt;/dd&gt; &lt;/dl&gt; &lt;p&gt;&lt;strong&gt;Tell us how to get in touch with you:&lt;/strong&gt;&lt;/p&gt; &lt;dl&gt; &lt;dd&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Name*&lt;/td&gt; &lt;td&gt; &lt;input type="text" size="40" maxlength="256" name="name" id="name" value="&lt;?php echo $_GET['name'];?&gt;"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Company&lt;/td&gt; &lt;td&gt; &lt;input type="text" size="40" maxlength="256" name="company" value="&lt;?php echo $_GET['company'];?&gt;"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Email*&lt;/td&gt; &lt;td&gt;&lt;input type="text" size="40" maxlength="256" name="email" id="email" value="&lt;?php echo $_GET['email'];?&gt;"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Phone&lt;/td&gt; &lt;td&gt;&lt;input type="text" size="40" maxlength="256" name="phone" value="&lt;?php echo $_GET['phone'];?&gt;"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;City&lt;/td&gt; &lt;td&gt;&lt;input type="text" size="40" maxlength="256" name="city" value="&lt;?php echo $_GET['city'];?&gt;"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/dd&gt; &lt;/dl&gt; &lt;p&gt;&lt;strong&gt;Best method to get in touch with you:&lt;/strong&gt;&lt;/p&gt; &lt;dl&gt; &lt;dd&gt;&lt;input type="radio" name="ContactMethod" value="telephone&lt;?php echo $_GET['InterestedIn'];?&gt;" checked="checked"&gt; Phone &lt;input type="radio" name="ContactMethod" value="email&lt;?php echo $_GET['InterestedIn'];?&gt;"&gt; Email &lt;/dd&gt; &lt;/dl&gt; </code></pre> <dl><dd> " alt="verification image, type it in the box" width="50" height="24" align="top" />&nbsp;&nbsp;<br /><br /> Enter Verification Image </dd></dl> <pre><code>&lt;p style="padding-left:60px;"&gt;&lt;input type="submit" class="button primary" value="Submit Form" name="submit"/&gt; &lt;input type="reset" class="button primary" value="Clear Form" name"clear" /&gt;&lt;/p&gt; </code></pre> <p></p> <p>and then at the bottom of the page after the /html tag:</p> <pre><code>&lt;?php } else if ($state == 1) { ?&gt; &lt;h3&gt;Error&lt;/h3&gt; &lt;p&gt;Wrong Verification Code Entered - Go back and try again&lt;/p&gt; &lt;?php } else if ($state == 2) { ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; </code></pre> <p>and then the rest of the html here... for the successful page submitted and then the closing php tag.</p> <p>Any ideas why it stopped working? Any way to fix this with in the current code? If not, I need some way to tell the user of the form that they have submitted the wrong verification code. Currently, if you enter the wrong code it just refreshes the current page. </p> <p>Any help would be greatly appreciated. I am not well versed in php, so please use lamens terms!</p> <p>Javascript:</p> <pre><code>&lt;script type="text/JavaScript"&gt; &lt;!-- function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))&gt;0&amp;&amp;parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&amp;&amp;d.all) x=d.all[n]; for (i=0;!x&amp;&amp;i&lt;d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&amp;&amp;d.layers&amp;&amp;i&lt;d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x &amp;&amp; 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&lt;(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&lt;1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { 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&lt;min || max&lt;num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } //--&gt; &lt;/script&gt; </code></pre> <p>Verificationimage.php file code:</p> <pre><code>&lt;?php // ----------------------------------------- // The Web Help .com // ----------------------------------------- header('Content-type: image/jpeg'); $width = 50; $height = 24; $my_image = imagecreatetruecolor($width, $height); imagefill($my_image, 0, 0, 0xFFFFFF); // add noise for ($c = 0; $c &lt; 40; $c++){ $x = rand(0,$width-1); $y = rand(0,$height-1); imagesetpixel($my_image, $x, $y, 0x000000); } $x = rand(1,10); $y = rand(1,10); $rand_string = rand(1000,9999); imagestring($my_image, 5, $x, $y, $rand_string, 0x000000); setcookie('tntcon',(md5($rand_string).'a4xn')); imagejpeg($my_image); imagedestroy($my_image); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload