PHP - Problem With Securimage.php Always Rejecting Captcha Input
I have a form with a captcha at the end of it (using securimage.php - http://www.phpcaptcha.org/documentation/quickstart/).
But no matter what I enter into the field, it always gives me the error message: Quote: Quote The code you entered was incorrect. Go back and try again. If echo out $securimage->check($_POST['captcha_code']) Then I am given '1', which shows that the date entered does in fact match the text that is displayed within the captcha image. But it just seems to be ignoring this in the if statement! I've even tried simplifying the if statement like so: if (!$securimage->check($_POST['captcha_code'])) { But that STILL gives me the error message even when I've been sure to enter something into the name field. It's as if there is something about the if statement that the script just doesn't seem to like?! If anybody has any ideas what might be wrong that would be great Here's my code (please excuse the ugly HTML, it's not mine!) Code: [Select] <!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" /> --></style> <script type="text/javascript" src="script/jquery-1.4.2.min.js"></script> <link href="script/jquery-datepicker/datePicker.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="script/jquery-datepicker/date.js"></script> <script type="text/javascript" src="script/jquery-datepicker/jquery.datePicker.js"></script> <script type="text/javascript" src="script/jquery-datepicker/call.js"></script> <script type="text/javascript" src="script/jquery-datepicker/call-2.js"></script> <csscriptdict import="import"> <script type="text/javascript" src="GeneratedItems/CSScriptLib.js"></script> </csscriptdict> <csactiondict> <script type="text/javascript"><!-- var preloadFlag = false; function preloadImages() { if (document.images) { pre_head1_up = newImage('images/head1_up.jpg'); pre_head8_up = newImage('images/head8_up.jpg'); pre_head8_down = newImage('images/head8_down.jpg'); pre_head7_up = newImage('images/head7_up.jpg'); pre_head3_up = newImage('images/head3_up.jpg'); pre_head6_up = newImage('images/head6_up.jpg'); pre_head4_up = newImage('images/head4_up.jpg'); pre_head5_up = newImage('images/head5_up.jpg'); preloadFlag = true; } } // --></script> </csactiondict> </head> <body onload="preloadImages();" bgcolor="#FFFFFF" text="#000000"> <div align="center"> <table width="750" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="00" rowspan="5" valign="top" width="79"> <div align="center"> <h4 class="00"><a onmouseover="changeImages('Curriculum','images/head1_up.jpg');MM_swapImage('Curriculum','','Images/head1_up.jpg',1);return true" onmouseout="changeImages('Curriculum','images/head1_down.jpg');MM_swapImgRestore();return true" href="curriculum.html" target="_self"><img src="images/head1_down.jpg" alt="Curriculum Button" name="Curriculum" height="45" width="47" border="0"/></a><br/> <b><font size="2" color="#0000CC" face="Comic Sans MS">Curriculum</font></b></h4> </div> </td> <td width="79" height="11"></td> <td width="79"></td> <td width="79"></td> <td rowspan="8" valign="bottom" width="119"><a href="index.html"><img src="images/sml_logo.jpg" alt="Tinks Logo Home Button" height="108" width="119" border="0"/></a></td> <td width="77"></td> <td width="79"></td> <td width="79"></td> <td class="00" rowspan="5" valign="top" width="79"> <div align="center"> <h4 class="00"><a onmouseover="changeImages('Contact_Us','images/head8_up.jpg');return true" onmouseout="changeImages('Contact_Us','images/head8_down.jpg');return true" href="contact.html" target="_self"><img src="images/head8_down.jpg" alt="Contact Us Buttons" name="Contact_Us" height="45" width="47" border="0"/></a><br/> <b><font size="2" color="#0000CC" face="Comic Sans MS"><span>Contact Us</span></font></b></h4> </div> </td> <td width="1"></td> </tr> <tr> <td class="00" rowspan="5" valign="top"> <div align="center"> <h4 class="00"><img src="images/head2_down.jpg" alt="Register Button" name="Register" height="45" width="47" border="0"/><br/> <b><font size="2" color="#0000CC" face="Comic Sans MS">Register</font></b></h4> </div> </td> <td height="10"></td> <td></td> <td></td> <td></td> <td class="00" rowspan="5" valign="top" width="79"> <div align="center"> <h4 class="00"><a onmouseover="changeImages('Parents','images/head7_up.jpg');MM_swapImage('Parents','','Images/head7_up.jpg',1);return true" onmouseout="changeImages('Parents','images/head7_down.jpg');MM_swapImgRestore();return true" href="parents.html" target="_self"><img src="images/head7_down.jpg" alt="Parents Testimonials Button" name="Parents" height="45" width="47" border="0"/></a><br/> <font color="#0000CC"><b><font size="2" face="Comic Sans MS">Parent<br/> Testimonials</font></b></font></h4> </div> </td> <td></td> </tr> <tr> <td class="00" rowspan="5" valign="top"> <div align="center"> <h4 class="00"><a onmouseover="changeImages('Health&Safety','images/head3_up.jpg');MM_swapImage('Health&Safety','','Images/head3_up.jpg',1);return true" onmouseout="changeImages('Health&Safety','images/head3_down.jpg');MM_swapImgRestore();return true" href="health_safety.html" target="_self"><img src="images/head3_down.jpg" alt="Health & Safety Button" name="Health&Safety" height="45" width="47" border="0"/></a><br/> <b><font size="2" color="#0000CC" face="Comic Sans MS">Health & Safety</font></b></h4> </div> </td> <td height="12"></td> <td></td> <td class="00" rowspan="5" align="center" valign="top"> <div align="center"> <a onmouseover="MM_swapImage('Events','','Images/head6_up.jpg',1)" onmouseout="MM_swapImgRestore()" href="../../web/htdocs/events.htm"><font size="2" face="Comic Sans MS"><b></b></font></a> <h4 class="00"><a onmouseover="changeImages('Events','images/head6_up.jpg');return true" onmouseout="changeImages('Events','images/head6_down.jpg');return true" href="events.html"><img id="Events" src="images/head6_down.jpg" alt="Events Button" name="Events" height="45" width="47" border="0"/></a><font color="#0000CC"><b><font size="2" face="Comic Sans MS"><br/> Events</font></b></font></h4> </div> </td> <td></td> </tr> <tr> <td class="00" rowspan="5" valign="top"> <div align="center"> <h4 class="00"><a onmouseover="changeImages('Team','images/head4_up.jpg');MM_swapImage('Team','','Images/head4_up.jpg',1);return true" onmouseout="changeImages('Team','images/head4_down.jpg');MM_swapImgRestore();return true" href="team.html" target="_self"><img src="images/head4_down.jpg" alt="Team Button" name="Team" height="45" width="47" border="0"/></a><br/> <b><font size="2" color="#0000CC" face="Comic Sans MS">The Team</font></b></h4> </div> </td> <td height="8"></td> <td></td> </tr> <tr> <td class="00" rowspan="4" align="center" valign="top"> <h4 class="00"><a onmouseover="changeImages('Fees','images/head5_up.jpg');MM_swapImage('Fees','','Images/head5_up.jpg',1);return true" onmouseout="changeImages('Fees','images/head5_down.jpg');MM_swapImgRestore();return true" href="fees.html" target="_self"><img src="images/head5_down.jpg" alt="Fees Button" name="Fees" height="45" width="47" border="0"/></a><br/> <font color="#0000CC"><b><font size="2" face="Comic Sans MS">Fees</font></b></font></h4> </td> <td height="34"></td> </tr> <tr> <td height="19"></td> <td></td> <td></td> </tr> <tr> <td height="10"></td> <td></td> <td width="79"></td> <td></td> <td></td> </tr> <tr> <td height="12"></td> <td></td> <td></td> <td></td> <td width="79"></td> <td></td> <td></td> </tr> </table> <table width="742" border="0" cellpadding="0" cellspacing="0" height="300 " align="center"> <tr> <td height="72" valign="top" colspan="8"> <div align="center"> <h1 align="center"><font face="Comic Sans MS" size="6" color="#A94BD3"><b>Register</b></font></h1> </div> </script><div style="color:red;font-weight:bold;"></div> <form method="post" action="script/enquiry.php"> <input type="hidden" name="thankspage" value="register-thanks.php" /> <div><label>Child's Full Name <span class="highlight">*</span></label><input type="text" name="ChildsFullName" id="ChildsFullName" class="required" /></div> <div> <label for="DateDD">Date <span class="highlight">*</span></label> <select id="DateDD" name="DateDD"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select id="DateMM" name="DateMM"> <option value="1">Jan</option> <option value="2">Feb</option> <option value="3">Mar</option> <option value="4">Apr</option> <option value="5">May</option> <option value="6">Jun</option> <option value="7">Jul</option> <option value="8">Aug</option> <option value="9">Sep</option> <option value="10">Oct</option> <option value="11">Nov</option> <option value="12">Dec</option> </select> <select id="DateYYYY" name="DateYYYY"> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> </select> <a id="date-pick" href="#" class="dp-applied"><img src="script/jquery-datepicker/image/frm-date.gif" /></a> </div> <div><label>Name of Parent/Guardian <span class="highlight">*</span></label><input type="text" name="ParentGuardian" id="ParentGuardian" /></div> <div> <div class="left"> <label>Address <span class="highlight">*</span></label> </div> <div class="right"> <div><label>Street Address</label><input type="text" name="StreetAddress" id="1234" /></div> <div><label>Address Line 2</label><input type="text" name="AddressLine2" id="1234" /></div> <div><label>City</label><input type="text" name="City" id="1234" /></div> <div><label>Post Code</label><input type="text" name="PostCode" id="1234" /></div> <div><label>State/Province/Region</label><input type="text" name="StateProvinceRegion" id="1234" /></div> <div><label>Country</label> <select name="Country" id="Country"><option value=""></option><optgroup label="North America"><option value="Antigua and Barbuda">Antigua and Barbuda</option><option value="Aruba,Bahamas">Aruba,Bahamas</option><option value="Barbados">Barbados</option><option value="Belize">Belize</option><option value="Canada">Canada</option><option value="Cook Islands">Cook Islands</option><option value="Costa Rica">Costa Rica</option><option value="Cuba">Cuba</option><option value="Dominica">Dominica</option><option value="Dominican Republic">Dominican Republic</option><option value="El Salvador">El Salvador</option><option value="Grenada">Grenada</option><option value="Guatemala">Guatemala</option><option value="Haiti">Haiti</option><option value="Honduras">Honduras</option><option value="Jamaica">Jamaica</option><option value="Mexico">Mexico</option><option value="Netherlands Antilles">Netherlands Antilles</option><option value="Nicaragua">Nicaragua</option><option value="Panama ">Panama </option><option value="Puerto Rico ">Puerto Rico </option><option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option><option value="Saint Lucia">Saint Lucia</option><option value="Saint Vincent and the Grenadines">Saint Vincent and the Grenadines</option><option value="Trinidad and Tobago">Trinidad and Tobago</option><option value="United States">United States</option></optgroup><optgroup label="South America"><option value="Argentina">Argentina</option><option value="Bolivia">Bolivia</option><option value="Brazil">Brazil</option><option value="Chile">Chile</option><option value="Colombia">Colombia</option><option value="Ecuador">Ecuador</option><option value="Guyana">Guyana</option><option value="Paraguay">Paraguay</option><option value="Peru">Peru</option><option value="Suriname">Suriname</option><option value="Uruguay">Uruguay</option><option value="Venezuela">Venezuela</option></optgroup><optgroup label="Europe"><option value="Albania">Albania</option><option value="Andorra">Andorra</option><option value="Armenia">Armenia</option><option value="Austria">Austria</option><option value="Azerbaijan">Azerbaijan</option><option value="Belarus">Belarus</option><option value="Belgium">Belgium</option><option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option><option value="Bulgaria">Bulgaria</option><option value="Croatia">Croatia</option><option value="Cyprus">Cyprus</option><option value="Czech Republic">Czech Republic</option><option value="Denmark">Denmark</option><option value="Estonia">Estonia</option><option value="Faroe Islands">Faroe Islands</option><option value="Finland">Finland</option><option value="France">France</option><option value="Georgia">Georgia</option><option value="Germany">Germany</option><option value="Greece">Greece</option><option value="Hungary">Hungary</option><option value="Iceland">Iceland</option><option value="Ireland">Ireland</option><option value="Italy">Italy</option><option value="Latvia">Latvia</option><option value="Liechtenstein">Liechtenstein</option><option value="Lithuania">Lithuania</option><option value="Luxembourg">Luxembourg</option><option value="Macedonia">Macedonia</option><option value="Malta">Malta</option><option value="Moldova">Moldova</option><option value="Monaco">Monaco</option><option value="Montenegro">Montenegro</option><option value="Netherlands">Netherlands</option><option value="Norway">Norway</option><option value="Poland">Poland</option><option value="Portugal">Portugal</option><option value="Romania">Romania</option><option value="San Marino">San Marino</option><option value="Serbia">Serbia</option><option value="Slovakia">Slovakia</option><option value="Slovenia">Slovenia</option><option value="Spain">Spain</option><option value="Sweden">Sweden</option><option value="Switzerland">Switzerland</option><option value="Ukraine">Ukraine</option><option selected="selected" value="United Kingdom">United Kingdom</option><option value="Vatican City">Vatican City</option></optgroup><optgroup label="Asia"><option value="Afghanistan">Afghanistan</option><option value="Bahrain">Bahrain</option><option value="Bangladesh">Bangladesh</option><option value="Bhutan">Bhutan</option><option value="Brunei Darussalam">Brunei Darussalam</option><option value="Myanmar">Myanmar</option><option value="Cambodia">Cambodia</option><option value="China">China</option><option value="East Timor">East Timor</option><option value="Hong Kong">Hong Kong</option><option value="India">India</option><option value="Indonesia">Indonesia</option><option value="Iran">Iran</option><option value="Iraq">Iraq</option><option value="Israel">Israel</option><option value="Japan">Japan</option><option value="Jordan">Jordan</option><option value="Kazakhstan">Kazakhstan</option><option value="North Korea">North Korea</option><option value="South Korea">South Korea</option><option value="Kuwait">Kuwait</option><option value="Kyrgyzstan">Kyrgyzstan</option><option value="Laos">Laos</option><option value="Lebanon">Lebanon</option><option value="Malaysia">Malaysia</option><option value="Maldives">Maldives</option><option value="Mongolia">Mongolia</option><option value="Nepal">Nepal</option><option value="Oman">Oman</option><option value="Pakistan">Pakistan</option><option value="Palestine">Palestine</option><option value="Philippines">Philippines</option><option value="Qatar">Qatar</option><option value="Russia">Russia</option><option value="Saudi Arabia">Saudi Arabia</option><option value="Singapore">Singapore</option><option value="Sri Lanka">Sri Lanka</option><option value="Syria">Syria</option><option value="Taiwan">Taiwan</option><option value="Tajikistan">Tajikistan</option><option value="Thailand">Thailand</option><option value="Turkey">Turkey</option><option value="Turkmenistan">Turkmenistan</option><option value="United Arab Emirates">United Arab Emirates</option><option value="Uzbekistan">Uzbekistan</option><option value="Vietnam">Vietnam</option><option value="Yemen">Yemen</option></optgroup><optgroup label="Oceania"><option value="Australia">Australia</option><option value="Fiji">Fiji</option><option value="Kiribati">Kiribati</option><option value="Marshall Islands">Marshall Islands</option><option value="Micronesia">Micronesia</option><option value="Nauru">Nauru</option><option value="New Zealand">New Zealand</option><option value="Palau">Palau</option><option value="Papua New Guinea">Papua New Guinea</option><option value="Samoa">Samoa</option><option value="Solomon Islands">Solomon Islands</option><option value="Tonga">Tonga</option><option value="Tuvalu">Tuvalu</option><option value="Vanuatu">Vanuatu</option></optgroup><optgroup label="Africa"><option value="Algeria">Algeria</option><option value="Angola">Angola</option><option value="Benin">Benin</option><option value="Botswana">Botswana</option><option value="Burkina Faso">Burkina Faso</option><option value="Burundi">Burundi</option><option value="Cameroon">Cameroon</option><option value="Cape Verde">Cape Verde</option><option value="Central African Republic">Central African Republic</option><option value="Chad">Chad</option><option value="Comoros">Comoros</option><option value="Democratic Republic of the Congo">Democratic Republic of the Congo</option><option value="Republic of the Congo">Republic of the Congo</option><option value="Djibouti">Djibouti</option><option value="Egypt">Egypt</option><option value="Equatorial Guinea">Equatorial Guinea</option><option value="Eritrea">Eritrea</option><option value="Ethiopia">Ethiopia</option><option value="Gabon">Gabon</option><option value="Gambia">Gambia</option><option value="Ghana">Ghana</option><option value="Gibraltar">Gibraltar</option><option value="Guinea">Guinea</option><option value="Guinea-Bissau">Guinea-Bissau</option><option value="Cote d'Ivoire">Cote d'Ivoire</option><option value="Kenya">Kenya</option><option value="Lesotho">Lesotho</option><option value="Liberia">Liberia</option><option value="Libya">Libya</option><option value="Madagascar">Madagascar</option><option value="Malawi">Malawi</option><option value="Mali">Mali</option><option value="Mauritania">Mauritania</option><option value="Mauritius">Mauritius</option><option value="Morocco">Morocco</option><option value="Mozambique">Mozambique</option><option value="Namibia">Namibia</option><option value="Niger">Niger</option><option value="Nigeria">Nigeria</option><option value="Rwanda">Rwanda</option><option value="Sao Tome and Principe">Sao Tome and Principe</option><option value="Senegal">Senegal</option><option value="Seychelles">Seychelles</option><option value="Sierra Leone">Sierra Leone</option><option value="Somalia">Somalia</option><option value="South Africa">South Africa</option><option value="Sudan">Sudan</option><option value="Swaziland">Swaziland</option><option value="United Republic of Tanzania">United Republic of Tanzania</option><option value="Togo">Togo</option><option value="Tunisia">Tunisia</option><option value="Uganda">Uganda</option><option value="Zambia">Zambia</option><option value="Zimbabwe">Zimbabwe</option></optgroup></select> </div> </div> </div> <div><label>Phone Number <span class="highlight">*</span></label><input type="text" name="PhoneNumber" id="1234" /></div> <div><label>Place of work</label><input type="text" name="PlaceOfWork" id="1234" /></div> <div> <label>Mornings only</label> <div class="right"> <input type="checkbox" name="MorningsOnly" value="Monday" />Monday <input type="checkbox" name="MorningsOnly" value="Tuesday" />Tuesday <input type="checkbox" name="MorningsOnly" value="Wednesday" />Wednesday <input type="checkbox" name="MorningsOnly" value="Thursday" />Thursday <input type="checkbox" name="MorningsOnly" value="Friday" />Friday <p>Please indicate the sessions you wish your child to attend by ticking the appropriate boxes:</p> </div> </div> <div> <label>Afternoons only</label> <div class="right"> <input type="checkbox" name="AfternoonsOnly" value="Monday" />Monday <input type="checkbox" name="AfternoonsOnly" value="Tuesday" />Tuesday <input type="checkbox" name="AfternoonsOnly" value="Wednesday" />Wednesday <input type="checkbox" name="AfternoonsOnly" value="Thursday" />Thursday <input type="checkbox" name="AfternoonsOnly" value="Friday" />Friday <p>Please indicate the sessions you wish your child to attend by ticking the appropriate boxes:</p> </div> </div> <div> <label>Full days</label> <div class="right"> <input type="checkbox" name="FullDays" value="Monday" />Monday <input type="checkbox" name="FullDays" value="Tuesday" />Tuesday <input type="checkbox" name="FullDays" value="Wednesday" />Wednesday <input type="checkbox" name="FullDays" value="Thursday" />Thursday <input type="checkbox" name="FullDays" value="Friday" />Friday <p>Please indicate the sessions you wish your child to attend by ticking the appropriate boxes:</p> </div> </div> <div><label>Does your child have special requirements?</label><input type="text" name="SpecialRequirements" id="SpecialRequirements" /></div> <div><label>Please provide any other relevant information </label><input type="text" name="RelevantInfo" id="RelevantInfo" /></div> <div> <div> <label for="DateStartDD">Date you wish your child to start</label> <select id="DateStartDD" name="DateStartDD"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select id="DateStartMM" name="DateStartMM"> <option value="1">Jan</option> <option value="2">Feb</option> <option value="3">Mar</option> <option value="4">Apr</option> <option value="5">May</option> <option value="6">Jun</option> <option value="7">Jul</option> <option value="8">Aug</option> <option value="9">Sep</option> <option value="10">Oct</option> <option value="11">Nov</option> <option value="12">Dec</option> </select> <select id="DateStartYYYY" name="DateStartYYYY"> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> <option value="2015">2015</option> <option value="2016">2016</option> <option value="2017">2017</option> <option value="2018">2018</option> <option value="2019">2019</option> <option value="2020">2020</option> </select> <a id="date-pick-2" href="#" class="dp-applied"><img src="script/jquery-datepicker/image/frm-date.gif" /></a> </div> </div> <div><label>Email <span class="highlight">*</span></label><input type="text" name="submitteremail" id="Email" /></div> <div id="captcha-div"> <label>Please type the text displayed in the image</label> <img id="captcha" src="script/securimage/securimage_show.php" alt="CAPTCHA Image" /> <input type="text" name="captcha_code" size="10" maxlength="6" /> </div> <div><input type="submit" name="submit" value="Submit" /></div> </form> </html> <?php session_start(); include_once 'securimage/securimage.php'; $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { die('The code you entered was incorrect. Go back and try again.'); } ?> <?php *** Rest of PHP script to send email *** Similar TutorialsThis topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=357935.0 Hello all! First post. Wondering if anyone could help me out with a problem I've been having with a form mailer... I had it working at one point in time, but now not so much. I'm using Securimage as a captcha The file is email.php My problem is... When you type in the code wrong, it tells you its wrong. When you type the code right, it redirects to thank.html, which is correct...but never sends the mail! Am I missing something obvious? Here's my code: Code: [Select] <?php session_start(); //include_once $_SERVER['DOCUMENT_ROOT'] . '/coaxicom_email_original/securimage/securimage.php'; include_once('securimage/securimage.php'); $securimage = new Securimage(); if( isset($_POST['submit'])) { if ($securimage->check($_POST['captcha_code']) == false) { // the code was incorrect // you should handle the error so that the form processor doesn't continue // or you can use the following code if there is no validation or you do not know how echo "The security code entered was incorrect.<br /><br />"; echo "<a href='email.php'>Please click this link to back and try again.</a>"; exit; } //Data $contact1 = $_POST['contact1']; $company1 = $_POST['company1']; $email1 = $_POST['email1']; $phone1 = $_POST['phone1']; $country1 = $_Post['country1']; $address1 = $_POST['address1']; $city1 = $_POST['city1']; $state1 = $_POST['state1']; $zip1 = $_POST['zip1']; $contact2 = $_POST['contact2']; $company2 = $_POST['company2']; $email2 = $_POST['email2']; $phone2 = $_POST['phone2']; $country2 = $_Post['country2']; $address2 = $_POST['address2']; $city2 = $_POST['city2']; $state2 = $_POST['state2']; $zip2 = $_POST['zip2']; $contact3 = $_POST['contact3']; $company3 = $_POST['company3']; $email3 = $_POST['email3']; $phone3 = $_POST['phone3']; $country3 = $_Post['country3']; $address3 = $_POST['address3']; $city3 = $_POST['city3']; $state3 = $_POST['state3']; $zip3 = $_POST['zip3']; $contact4 = $_POST['contact4']; $company4 = $_POST['company4']; $email4 = $_POST['email4']; $phone4 = $_POST['phone4']; $country4 = $_Post['country4']; $address4 = $_POST['address4']; $city4 = $_POST['city4']; $state4 = $_POST['state4']; $zip4 = $_POST['zip4']; $contact5 = $_POST['contact5']; $company5 = $_POST['company5']; $email5 = $_POST['email5']; $phone5 = $_POST['phone5']; $country5 = $_Post['country5']; $address5 = $_POST['address5']; $city5 = $_POST['city5']; $state5 = $_POST['state5']; $zip5 = $_POST['zip5']; $contact6 = $_POST['contact6']; $company6 = $_POST['company6']; $email6 = $_POST['email6']; $phone6 = $_POST['phone6']; $country6 = $_Post['country6']; $address6 = $_POST['address6']; $city6 = $_POST['city6']; $state6 = $_POST['state6']; $zip6 = $_POST['zip6']; $contact7 = $_POST['contact7']; $company7 = $_POST['company7']; $email7 = $_POST['email7']; $phone7 = $_POST['phone7']; $country7 = $_Post['country7']; $address7 = $_POST['address7']; $city7 = $_POST['city7']; $state7 = $_POST['state7']; $zip7 = $_POST['zip7']; $contact8 = $_POST['contact8']; $company8 = $_POST['company8']; $email8 = $_POST['email8']; $phone8 = $_POST['phone8']; $country8 = $_Post['country8']; $address8 = $_POST['address8']; $city8 = $_POST['city8']; $state8 = $_POST['state8']; $zip8 = $_POST['zip8']; $body = <<<EOD <br /><hr><br /> Company: $company1 <br /> Contact: $contact1 <br /> Email: $email1 <br /> Phone: $phone1 <br /> Country: $country1 <br /> Address: $address1 <br /> City: $city1 <br /> State: $state1 <br /> Zip: $zip1 <br /> <br /><hr><br /> Company: $company2 <br /> Contact: $contact2 <br /> Email: $email2 <br /> Phone: $phone2 <br /> Country: $country2 <br /> Address: $address2 <br /> City: $city2 <br /> State: $state2 <br /> Zip: $zip2 <br /> <br /><hr><br /> Company: $company3 <br /> Contact: $contact3 <br /> Email: $email3 <br /> Phone: $phone3 <br /> Country: $country3 <br /> Address: $address3 <br /> City: $city3 <br /> State: $state3 <br /> Zip: $zip3 <br /> <br /><hr><br /> Company: $company4 <br /> Contact: $contact4 <br /> Email: $email4 <br /> Phone: $phone4 <br /> Country: $country4 <br /> Address: $address4 <br /> City: $city4 <br /> State: $state4 <br /> Zip: $zip4 <br /> <br /><hr><br /> Company: $company5 <br /> Contact: $contact5 <br /> Email: $email5 <br /> Phone: $phone5 <br /> Country: $country5 <br /> Address: $address5 <br /> City: $city5 <br /> State: $state5 <br /> Zip: $zip5 <br /> <br /><hr><br /> Company: $company6 <br /> Contact: $contact6 <br /> Email: $email6 <br /> Phone: $phone6 <br /> Country: $country6 <br /> Address: $address6 <br /> City: $city6 <br /> State: $state6 <br /> Zip: $zip6 <br /> <br /><hr><br /> Company: $company7 <br /> Contact: $contact7 <br /> Email: $email7 <br /> Phone: $phone7 <br /> Country: $country7 <br /> Address: $address7 <br /> City: $city7 <br /> State: $state7 <br /> Zip: $zip7 <br /> <br /><hr><br /> Company: $company8 <br /> Contact: $contact8 <br /> Email: $email8 <br /> Phone: $phone8 <br /> Country: $country8 <br /> Address: $address8 <br /> City: $city8 <br /> State: $state8 <br /> Zip: $zip8 <br /> <br /><hr><br /> EOD; //Subject and Email $emailSubject = 'This is my subject'; $webMaster = 'example@gmail.com'; $headers = "From: Example\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster,$emailSubject,$body,$headers); header( "Location: thank.html" ); } else { ?> <!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></head> <body> <div id="wrapper"> <div id="main"> <div id="fContainer"> <form action="email.php" method="post" > <div class="fbox" id="f1"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company1" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact1" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email1" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone1" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country1" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address1" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city1" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state1" /></div></div> <br /> <!-- end #f1 --></div> <div class="fbox" id="f2"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company2" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact2" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email2" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone2" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country2" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address2" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city2" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state2" /></div></div> <br /> <!-- end #f2 --></div> <div class="fbox" id="f3"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company3" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact3" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email3" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone3" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country3" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address3" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city3" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state3" /></div></div> <br /> <!-- end #f3 --></div> <div class="fbox" id="f4"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company4" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact4" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email4" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone4" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country4" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address4" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city4" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state4" /></div></div> <br /> <!-- end #f4 --></div> <div class="fbox" id="f5"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company5" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact5" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email5" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone5" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country5" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address5" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city5" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state5" /></div></div> <br /> <!-- end #f5 --></div> <div class="fbox" id="f6"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company6" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact6" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email6" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone6" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country6" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address6" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city6" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state6" /></div></div> <br /> <!-- end #f6 --></div> <div class="fbox" id="f7"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company7" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact7" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email7" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone7" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country7" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address7" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city7" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state7" /></div></div> <br /> <!-- end #f7 --></div> <div class="fbox" id="f8"> <div class="fLine"><div class="fLabel">Company Name:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="company8" /></div></div> <br /> <div class="fLine"><div class="fLabel">Contact:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="contact8" /></div></div> <br /> <div class="fLine"><div class="fLabel">E-mail:</div> <div class="fInput"><input type="text" size="25" maxlength="150" name="email8" /></div></div> <br /> <div class="fLine"><div class="fLabel">Phone:</div> <div class="fInput"><input type="text" size="15" maxlength="50" name="phone8" /></div></div> <br /> <div class="fLine"><div class="fLabel">Country:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="country8" /></div></div> <br /> <div class="fLine"><div class="fLabel">Address:</div> <div class="fInput"><input type="text" size="20" maxlength="300" name="address8" /></div></div> <br /> <div class="fLine"><div class="fLabel">City:</div> <div class="fInput"><input type="text" size="18" maxlength="100" name="city8" /></div></div> <br /> <div class="fLine"><div class="fLabel">State:</div> <div class="fInput"><input type="text" size="10" maxlength="100" name="state8" /></div></div> <br /> <!-- end #f8 --></div> <div id="fCaptcha"> <div id="codeLabel">Security Code<span class="red">*</span>:</div> <div id="img"><img id="captcha" src="securimage/securimage_show.php" alt="CAPTCHA Image" /></div> <div id="text"> <input type="text" name="captcha_code" size="10" maxlength="6" /></div> <!-- end #fCaptcha --></div> <div id="fCaptchaBox"></div> <div id="fSubmit"><input type="submit" name="submit" value="Email This Form" /></div> </form> <!-- end #fContainer --></div> <!-- end #main --></div> <!-- end #wrapper --></div> </body> </html> <?php } ?> I'm using the example_form from securimage. I have modified the email address in the php script to my email address and uploaded everything to my hosting company's FTP server. I then fill out the form and click the submit message button and the form says "The captcha was correct and the message has been sent!" but I never receive the email. I have other basic php forms that work just fine just for some reason I can't get this one working. Could someone please let me know if I'm missing something here? Thanks So far I have managed to create an upload process which uploads a picture, updates the database on file location and then tries to upload the db a 2nd time to update the Thumbnails file location (i tried updating the thumbnails location in one go and for some reason this causes failure) But the main problem is that it doesn't upload some files Here is my upload.php <?php include 'dbconnect.php'; $statusMsg = ''; $Title = $conn -> real_escape_string($_POST['Title']) ; $BodyText = $conn -> real_escape_string($_POST['ThreadBody']) ; // File upload path $targetDir = "upload/"; $fileName = basename($_FILES["file"]["name"]); $targetFilePath = $targetDir . $fileName; $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION); $Thumbnail = "upload/Thumbnails/'$fileName'"; if(isset($_POST["submit"]) && !empty($_FILES["file"]["name"])){ // Allow certain file formats $allowTypes = array('jpg','png','jpeg','gif','pdf', "webm", "mp4"); if(in_array($fileType, $allowTypes)){ // Upload file to server if(move_uploaded_file($_FILES["file"]["tmp_name"], $targetFilePath)){ // Insert image file name into database $insert = $conn->query("INSERT into Threads (Title, ThreadBody, filename) VALUES ('$Title', '$BodyText', '$fileName')"); if($insert){ $statusMsg = "The file ".$fileName. " has been uploaded successfully."; $targetFilePathArg = escapeshellarg($targetFilePath); $output=null; $retval=null; //exec("convert $targetFilePathArg -resize 300x200 ./upload/Thumbnails/'$fileName'", $output, $retval); exec("convert $targetFilePathArg -resize 200x200 $Thumbnail", $output, $retval); echo "REturned with status $retval and output:\n" ; if ($retval == null) { echo "Retval is null\n" ; echo "Thumbnail equals $Thumbnail\n" ; } }else{ $statusMsg = "File upload failed, please try again."; } }else{ $statusMsg = "Sorry, there was an error uploading your file."; } }else{ $statusMsg = 'Sorry, only JPG, JPEG, PNG, GIF, mp4, webm & PDF files are allowed to upload.'; } }else{ $statusMsg = 'Please select a file to upload.'; } //Update SQL db by setting the thumbnail column to equal $Thumbnail $update = $conn->query("update Threads set thumbnail = '$Thumbnail' where filename = '$fileName'"); if($update){ $statusMsg = "Updated the thumbnail to sql correctly."; echo $statusMsg ; } else { echo "\n Failed to update Thumbnail. Thumbnail equals $Thumbnail" ; } // Display status message echo $statusMsg; ?> And this does work on most files however it is not working on a 9.9mb png file which is named "test.png" I tested on another 3.3 mb gif file and that failed too? For some reason it returns the following Updated the thumbnail to sql correctly.Updated the thumbnail to sql correctly. Whereas on the files it works on it returns REturned with status 0 and output: Retval is null Thumbnail equals upload/Thumbnails/'rainbow-trh-stache.gif' Failed to update Thumbnail. Thumbnail equals upload/Thumbnails/'rainbow-trh-stache.gif'The file rainbow-trh-stache.gif has been uploaded successfully. Any idea on why this is? I want to build a captcha from scratch, as I'm all about doing things myself, and I've proposed a nice idea on how I can achieve that, but I'm sort of lost... What I want to do is write a script that will generate a random string of both letters and numbers, with the ability to set a limit on how many characters are generated. Then, I want to store that string within a variable called "random_string". Once the user types in that code, their input would get captured in a separate php file and stored within a variable like so: $captcha_code = $_POST['catpcha_code']; Then, I would write a code to see if the user's input matches the random character string from the html: Code: [Select] <?php if ($random_string == $captcha_code) { mail($to, $subject, $body); } else { echo ("The code you entered did not match the captcha. Please go back and try again."); } ?> Is this possible? I haven't yet tried it myself, because I don't know how to generate random strings of characters, but I was just wondering if perhaps I'm on the right track? Any suggestions or advice is appreciated =) The following code is what I am trying to use for doing a form captcha style verification and all it is throwing back when I load the page is an image of the website address. Does anyone here know where I am going wrong? I have been at this all day and gotten nowhere. Thanks in advance <?php session_start(); $rndval = rand(1000, 9999); $_SESSION['rndnum'] = md5($rndval); $img = imagecreate(60, 30); $bgc = imagecolorallocate ($img, 255, 251, 205); $fontcolor = imagecolorallocate ($img, 0, 0, 0); imagestring ($img, 5, 5, 8, $rndval, $fontcolor); header('Content-type: image/jpeg'); imagejpeg($img); imagedestroy($img); ?> Hi, I am making a CAPTCHA image. I am pretty sure the code I have is correct, but I am getting these error messages when I run the script. I use GoDaddy for hosting. The font that I reference in the script is in the root directory with the script. Any ideas? Thanks, Craig ------------ Warning: imagefilledrectangle(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 19 Warning: imageline(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 22 Warning: imageline(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 22 Warning: imageline(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 22 Warning: imageline(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 22 Warning: imageline(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 22 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagesetpixel(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 27 Warning: imagettftext() expects parameter 1 to be resource, null given in /home/content/68/6372768/html/captcha.php on line 30 Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/content/68/6372768/html/captcha.php on line 35 Code: [Select] <?php session_start(); // Set some important CAPTCHA constants define('CAPTCHA_NUMCHARS', 6); // number of characters in pass-phrase define('CAPTCHA_WIDTH', 100); // width of image define('CAPTCHA_HEIGHT', 25); // height of image // Generate the random pass-phrase $pass_phrase = ""; for ($i = 0; $i < CAPTCHA_NUMCHARS; $i++) { $pass_phrase .= chr(rand(97, 122)); } // Store the encrypted pass-phrase in a session variable $_SESSION['pass_phrase'] = sha1($pass_phrase); // Create the image $img = imagecreatetruecolor(CAPTCHA_WIDTH, CAPTCHA_HEIGHT); // Set a white background with black text and gray graphics $bg_color = imagecolorallocate($img, 255, 255, 255); // white $text_color = imagecolorallocate($img, 0, 0, 0); // black $graphic_color = imagecolorallocate($img, 64, 64, 64); // dark gray // Fill the background imagefilledrectangle($img, 0, 0, CAPTCHA_WIDTH, CAPTCHA_HEIGHT, $bg_color); // Draw some random lines for ($i = 0; $i < 5; $i++) { imageline($img, 0, rand() % CAPTCHA_HEIGHT, CAPTCHA_WIDTH, rand() % CAPTCHA_HEIGHT, $graphic_color); } // Sprinkle in some random dots for ($i = 0; $i < 50; $i++) { imagesetpixel($img, rand() % CAPTCHA_WIDTH, rand() % CAPTCHA_HEIGHT, $graphic_color); } // Draw the pass-phrase string imagettftext($img, 18, 0, 5, CAPTCHA_HEIGHT - 5, $text_color, 'Courier New Bold.ttf', $pass_phrase); // Output the image as a PNG using a header header("Content-type: image/png"); imagepng($img); // Clean up imagedestroy($img); ?> why does this not display my hosting supports gd Code: [Select] <?php session_start(); create_image(); function create_image() { $rand = md5(rand(0, 9999999)); $vaule = substr ($rand, 10, 8); //widht and height is the width of the box $width = 150; $height = 30; //the will be ther sixe of the box $image = imagecreate($width, $height); $black = imagecolorallocate($image, 0, 0, 0); $white = imagecolorallocate($image, 255, 255, 255); $grey = imagecolorallocate ($image, 132, 132, 132); $blue = imagecolorallocate ($image, 138, 197, 255); //the bg of the image imagefill($image, 0, 0, $blue); //imagetext imagestring($image, 5, 15, 7, $vaule, $black); //middle line and down line imageline($image, 0, $height/2, $width, $height/2, $grey); imageline($image, $width/2, 0, $width/2, $height, $grey); //hor line image($image, 0, 0, $width, $height, $grey); image($image, 0, $height, $width, 0, $grey); //desplay image imagepng($image); imagedestroy($image); //start session $_SESSION[captcha_key]; } ?> Hello everybody, I am new to these forums and registered due to my problems which has been annoying me all the evening... I've been googling for 3 hours and still haven't found a proper answer. The situation is: I started to use session in my page. <?php ini_set('session.use_cookies', 0); ini_set('session.use_only_cookies', 0); ini_set('session.name', 'sid'); ini_set('session.auto_start', 0); ini_set('session.use_trans_sid', 1); session_start(); ?> these lines are included in, let's say, my register.php file. (please, don't recommend me cookies as i'm developing a site for mobiles) And then, there is a form: <?php echo '<form action="register.php?sid='.session_id().'" method="POST"> Įveskite kodą:<br/> <input class="input" type="text" name="captcha" maxlength="4"/><br/> <img id="captcha" src="captcha.php?sid='.session_id().'" /><br/> <input type="submit" name="submit" value="Registruotis" /><br/> </form>';?> although captcha is shown, when I submit the form and i have to check inputs I get this error: Notice: Undefined index: randomnr2 in C:\Program Files\EasyPHP-5.3.3.1\www\new\register.php on line 144 Well, my captcha.php file: <?php $randomnr = rand(1000, 9999); $_SESSION['randomnr2'] = $randomnr; $im = imagecreatetruecolor(100, 38); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 150, 150, 150); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 200, 35, $black); //path to font - this is just an example you can use any font you like: $font = dirName(__FILE__).'/font/karate/Karate.ttf'; imagettftext($im, 20, 4, 22, 30, $grey, $font, $randomnr); imagettftext($im, 20, 4, 15, 32, $white, $font, $randomnr); //prevent caching on client side: header("Expires: Wed, 1 Jan 1997 00:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header ("Content-type: image/gif"); imagegif($im); imagedestroy($im); ?> Any ideas? Thanks in advance. Can anyone please take a quick glance at this form the captcha messages are not appearing correctly. The message keeps getting sent. Thank You Code: [Select] <?php if(($_SESSION['security_code'] != $_POST['security_code']) || (empty($_SESSION['security_code'])) ){ $to = "info@*******.com"; // change to your email address $name = htmlentities ($_POST['name']); $email = htmlentities ($_POST['email']); $phone = htmlentities ($_POST['phone']); $msg = htmlentities ($_POST['msg']); $d = date('l dS \of F Y h:i:s A'); $sub = "form to mail"; $headers = "From: $name <$email>\n"; $headers .= "Content-Type: text/plain; charset=iso-8859-1\n"; $mes = "phone: ".$phone."\n"; $mes .= "Message: ".$msg."\n"; $mes .= "Name: ".$name."\n"; $mes .= 'Email: '.$email."\n"; $mes .= 'Date & Time: '.$d; { mail($to, $sub, $mes, $headers); } echo "<p> </p><p> </p><p> </p><br />CAPTCHA CODE does not match! <p> </p><p> </p><a href='javascript:javascript:history.go(-1)'>Click here to go back to previous page</a>"; } else echo "THANK YOU"; ?> hi ,frds i am getting trouble . here is my problem captcha is working fine in firefox 3.6.16 but not in IE6 help me frds. Hi, I really need to add a captcha to this PHP process form? How do I go about doing this? Code: [Select] <?php // Define some constants define( "RECIPIENT_NAME", "John Smith" ); define( "RECIPIENT_EMAIL", "john@example.com" ); define( "EMAIL_SUBJECT", "Visitor Message" ); // Read the form values $success = false; $senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^\.\-\' a-zA-Z0-9]/", "", $_POST['senderName'] ) : ""; $senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^\.\-\_\@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : ""; $message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : ""; // If all values exist, send the email if ( $senderName && $senderEmail && $message ) { $recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">"; $headers = "From: " . $senderName . " <" . $senderEmail . ">"; $success = mail( $recipient, EMAIL_SUBJECT, $message, $headers ); } // Return an appropriate response to the browser if ( isset($_GET["ajax"]) ) { echo $success ? "success" : "error"; } else { ?> <html> <head> <title>Thanks!</title> </head> <body> <?php if ( $success ) echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>" ?> <?php if ( !$success ) echo "<p>There was a problem sending your message. Please try again.</p>" ?> <p>Click your browser's Back button to return to the page.</p> </body> </html> <?php } ?> ?? Thanks in advance! This is my first captcha script...it has 2 files, check.php and insert.php It works fine but I would like to hear your opinion what can I do to make it better? Is there any way that I can add random images ? Here is insert.php Code: [Select] <html> <body> <form action="check.php" method="post"> <img src="captcha.jpg"/> Insert captcha: <input type="text" name="cap"/> <input type="submit" value="submit"/> </form> </body> </html> here is check.php Code: [Select] <html> <body> <?php $cap= "flirc"; if ($_POST["cap"]==$cap) echo "Captcha is right!"; else echo " Captcha is wrong! "; ?> </body> </html>It is pretty basic, I know You can see it in action here Hello, I am trying to make a captcha, but having some trouble My code matches the tutorial I'm following, the 1st screenshot is the captcha.php file, the 2nd is the captcha_generate.php file, and the 3rd is the result in My browser, I am using firefox and linuxmint 10, with apache2 php5 and GD installed, any Help will be greatly appreciated!!!!! thanx GOD BLESS!!! [attachment deleted by admin] hi i was wondering if anyone had any idea how i can add code A to code b below? code a is my captcha code and code b is my contact form code thanks.. CODE A CAPTCHA: Code: [Select] <?php if(isset($_POST["captcha"])) if($_SESSION["captcha"]==$_POST["captcha"]) { echo 'CAPTHCA is valid; proceed the message'; } else { echo 'CAPTHCA is not valid; ignore submission'; } ?> CODE B CONTACT FORM: Code: [Select] <? $mailto = "me@blah.com"; $cc = ""; $bcc = ""; $subject = "Email subject"; $vname = "blah blah"; $email = $_POST['email']; function validateEmail($email) { if(eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,3})?(\.[a-zA-Z]{2,3})?$', $email)) return true; else return false; } if(strlen($_POST['name']) < 1 || strlen($_POST['message']) < 1 || validateEmail($email) == FALSE) { $emailerror = 'Error:'; if(empty($_POST['name'])) { $emailerror .= '<li>Enter name</li>'; } if(validateEmail($email) == FALSE) { $emailerror .= '<li>Enter valid email</li>'; } if(empty($_POST['message'])) { $emailerror .= '<li>Enter message</li>'; } } else { $emailerror .= "Your email has been sent successfully"; $timestamp = date("F j, Y, g:ia"); $messageproper ="\n\n" . "Name: " . ucwords($_POST['name']) . "\n" . "Email: " . ucwords($email) . "\n" . "Comments: " . $_POST['message'] . "\n" . "\n\n" ; $messageproper = trim(stripslashes($messageproper)); mail($mailto, $subject, $messageproper, "From: \"$vname\" <".$_POST['e_mail'].">\nReply-To: \"".ucwords($_POST['first_name'])."\" <".$_POST['e_mail'].">\nX-Mailer: PHP/" . phpversion() ); } ?> Hi I have a script below which I have put together from a couple of other scripts which simply adds an email address to a database for a newsletter and sends an email to the owner and to the user it then shows a success page. The script checks that the email is valid and there is also a captcha. The script works in that it only send out the emails if the captcha etc is entered correctly but the email is being added to the database regardless of whether the capture is correct or not. I was proud of myself for getting this far but would love some instruction on what I have missed and how to stop the email adding to the database unless it has passed the captcha. Below you will see the script. The commented out sections are parts of the old script I don't use. <?php require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_TESTING); $error = false; if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'send')) { //$name = tep_db_prepare_input($HTTP_POST_VARS['name']); $email_address = tep_db_prepare_input($HTTP_POST_VARS['email']); //$enquiry = tep_db_prepare_input($HTTP_POST_VARS['enquiry']); if (tep_validate_email($email_address) == false) { $error = true; $messageStack->add('testing', ENTRY_EMAIL_ADDRESS_CHECK_ERROR); } //CAPTHCA CODE start require(DIR_WS_FUNCTIONS . 'capcha_code.php'); $code_query = tep_db_query("select code from capcha_code where oscsid = '" . tep_session_id($HTTP_GET_VARS[tep_session_name()]) . "'"); $code_array = tep_db_fetch_array($code_query); $code = $code_array['code']; tep_db_query("DELETE FROM " . TABLE_CAPCTHA_CODE . " WHERE oscsid='" . $vvcode_oscsid . "'"); //remove the visual verify code associated with this session to clean database and ensure new results $user_entered_code = $HTTP_POST_VARS['capcha_code']; if (!(strcasecmp($user_entered_code, $code) == 0)) { //make the check case insensitive $error = true; $messageStack->add('testing', CAPCTHA_CODE_ENTRY_ERROR); } //CAPTHCA CODE stop /* testing sign up start */ if (isset($HTTP_POST_VARS['testing_sign_up'])) { $testing_query = tep_db_query("select testing_id_number from " . TABLE_TESTING_SIGN_UP . " where testing_email_address = '" . tep_db_input($email_address) . "'"); if(tep_db_num_rows($testing_query) == 0) { $sql_data_array = array('testing_email_address' => $email_address, 'testing_firstname' => "", 'testing_lastname' => ""); tep_db_perform(TABLE_TESTING_SIGN_UP, $sql_data_array); } } /* testing sign up end */ if ($error == false) { tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $email_address,STORE_OWNER_EMAIL_ADDRESS); tep_mail(MESSAGE_TEXT, $email_address, CUSTOMER_SUBJECT, NUMBER_ONE, STORE_OWNER_EMAIL_ADDRESS); tep_redirect(tep_href_link(FILENAME_TESTING, 'action=success')); } } $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_TESTING)); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?></title> <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>"> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </head> <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); ?> <!-- header_eof //--> <!-- body //--> <table border="0" width="100%" cellspacing="3" cellpadding="3"> <tr> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- left_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?> <!-- left_navigation_eof //--> </table></td><!-- body_text //--> <td width="100%" valign="top"><?php echo tep_draw_form('testing', tep_href_link(FILENAME_TESTING, 'action=send')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td><td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_contact_us.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td></tr> </table> </td></tr><td class="main"><?php echo INFORMATION_TEXT; ?></td> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td></tr> <?php if ($messageStack->size('testing') > 0) { ?> <tr> <td><?php echo $messageStack->output('testing'); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'success')) { ?> <tr> <td class="main" align="left"><?php echo tep_image(DIR_WS_IMAGES . 'clever.gif', HEADING_TITLE, '0', '0', 'align="left"') . TEXT_COMPLETE; ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> <?php } else { ?> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2" > <!--<tr> <td class="main"><?php echo ENTRY_NAME; ?></td> </tr> <tr> <td class="main"><?php echo tep_draw_input_field('name'); ?></td> </tr>//--> <tr><td class="main"><?php echo INSTRUCTIONS_TEXT; ?></td></tr> <tr> <td class="main"><?php echo ENTRY_EMAIL; ?> <?php echo tep_draw_input_field('email'); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <!--<tr> <td class="main"><?php echo ENTRY_ENQUIRY; ?></td> </tr> <tr> <td><?php echo tep_draw_textarea_field('enquiry', 'soft', 50, 15, $infotext); ?></td> </tr>//--> <!-- CAPTHCA CODE-- START--> <tr> <td class="main"><?php echo CAPCTHA_CODE_CATEGORY; ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" cellspacing="2" cellpadding="2"> <tr> <td class="main"><?php echo CAPCTHA_CODE_TEXT_INSTRUCTIONS; ?></td> <td class="main"> <?php // ----- begin garbage collection -------- tep_db_query("DELETE FROM " . TABLE_CAPCTHA_CODE . " WHERE dt < DATE_SUB(NOW(), INTERVAL 5 HOUR)"); // ----- end garbage collection -------- //can replace the following loop with $capcha_code = substr(str_shuffle (CAPCTHA_CODE_CHARACTER_POOL), 0, rand(3,4)); if you have PHP 4.3 $capcha_code = ""; for ($i = 1; $i <= rand(3,4); $i++){ $capcha_code = $capcha_code . substr(CAPCTHA_CODE_CHARACTER_POOL, rand(0, strlen(CAPCTHA_CODE_CHARACTER_POOL)-1), 1); } $vvcode_oscsid = tep_session_id($HTTP_GET_VARS[tep_session_name()]); tep_db_query("DELETE FROM " . TABLE_CAPCTHA_CODE . " WHERE oscsid='" . $vvcode_oscsid . "'"); $sql_data_array = array('oscsid' => $vvcode_oscsid, 'code' => $capcha_code); tep_db_perform(TABLE_CAPCTHA_CODE, $sql_data_array); $capcha_code = ""; echo('<img src="' . FILENAME_CAPCTHA_CODE_DISPLAY . '?vvc=' . $vvcode_oscsid . '"'); ?> </td> <td class="main"><?php echo CAPCTHA_CODE_BOX_IDENTIFIER; ?></td> <td class="main"><?php echo tep_draw_input_field('capcha_code'); ?></td> </tr> </table></td> </tr> </table></td> </tr> <!-- testing sign up start//--> <TD WIDTH="100%"> <tr> <td class="main" align="right"><?php echo ENTRY_TESTING_SIGN_UP; ?> <?php echo tep_draw_checkbox_field('testing_sign_up', '1', true); ?> </td></tr> <!--testing sign up end //--> <!-- CAPTHCA CODE-- STOP --> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </table></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> <td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td> <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td> </tr> </table></td> </tr> </table></td> </tr> <?php } ?> </table></form></td> <!-- body_text_eof //--> <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2"> <!-- right_navigation //--> <?php require(DIR_WS_INCLUDES . 'column_right.php'); ?> <!-- right_navigation_eof //--> </table></td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <!-- footer_eof //--> <br> </body> </html> <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> I wrote a small PHP with SQLite script which stores the IP with counter, it works fine with one problem, If I enter the correct password 4th time the counter becomes 4 and I get the error to enter my captcha. All the other times, 1-3 and 5 and above count it just works fine. What am I doing wrong with the logic.
Attaching the zip file with code.
https://drive.google...dit?usp=sharing
SO I have been developing a log in system and wanted to make my own simple CAPTCHA. I found one on the internet and ported the code across to get started and see how someone had made it. The issue I am having is that the dynamically generated image that I have created it seems is one step ahead of the session variable (the string is generated and then saved into session - then generates the image). But when i echo back the session it is always one step behind the actual image... Anyway here is my code and ask away please
<?php require('includes/util.inc.php'); $form = ' <form action="register.php" method="post"> <p>username <input type="text" name="username" id="usrinp"></p> <p>email <input type="text" name="email" id="emainp"></p> <p>password <input type="password" name="password1" id="psw1inp"></p> <p>re-enter password <input type="password" name="password2" id="psw2inp"></p> <p><img src="captcha.php"/></p> <p>captcha <input type="text" name="captcha" id="capinp"></p> <p><input type="submit" value="Register" id="subinp"></p> </form> '; if(isset($_SESSION['captcha'])) { echo $_SESSION['captcha']; } if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['username']) && !empty($_POST['email'])) { if($_POST['captcha'] == $_SESSION['captcha']) { $username = $_POST['username']; $email = $_POST['email']; $password = SHA1($_POST['password1']); $password = SHA1($_POST['password2']); $q = 'SELECT username FROM users WHERE username = :username'; $stmt = $pdo->prepare($q); $stmt->bindParam(':username', $username); $stmt->execute(); if($stmt->rowCount() > 0) { echo "<pre>This username has already been taken</pre>"; } else { $qi = 'INSERT INTO users ( username, password, email ) VALUES ( :username, SHA1(:password), :email )'; $query = $pdo->prepare($qi); $result = $query->execute( array( ':username'=>$username, ':password'=>$password, ':email'=>$email ) ); if($result) { header("location:login.php"); exit; } else { echo '<pre>Error, please try again</pre>'; } } } } $pageTitle = 'Register'; include('includes/header.inc.php'); include('pages/register.html'); ?> <?php require('includes/util.inc.php'); $string = ''; for ($i = 0; $i < 5; $i++) { $string .= chr(rand(97, 122)); } $_SESSION['captcha'] = $string; $font_path = 'includes/fonts/'; $captcha_image = imagecreatetruecolor(150, 60); $text_color = imagecolorallocate($captcha_image, 0, 0, 0); $bg_color = imagecolorallocate($captcha_image, 255, 255, 255); imagefilledrectangle($captcha_image, 0, 0, 399, 99, $bg_color); imagettftext($captcha_image, 30, 0, 10, 40, $text_color, $font_path . "dashdot.ttf", $_SESSION['captcha']); header("Content-type: image/png"); imagepng($captcha_image); ?> <?php session_start(); function class_loader($class) { require 'classes/' . $class . '.class' . '.php'; } spl_autoload_register('class_loader'); $user = (isset($_SESSION['user'])) ? $_SESSION['user'] : null; $cat = (isset($_SESSION['cat'])) ? $_SESSION['cat'] : null; try { $pdo = new PDO('mysql:dbname=phpcat; host=localhost', 'root', ''); } catch (PDOException $e) { $pageTitle = 'Error!'; include('header.inc.php'); include('../pages/error.html'); exit(); } Ideally just one word authentication and pretty simple, but effective. Preferebly one that does not use Sessions because then the user is unable to press the back button to go back to the original page after submitting the form... I know I could just put a text link there but not all users would click that link... How effective is Captcha anymore? How does using Captcha compare to using a Challenge Question like "2 + 3 = ??" I am creating a form on my website where users can e-mail me their comments - although my e-mail is hidden - and I don't want this to become a spam-magnet?! Debbie |