JeanieTallis Posted March 30, 2009 Share Posted March 30, 2009 I have a captcha on my website register form, and it doesn't display. This is my register form. (You don't need it all) <?php require_once('settings.php'); if ( array_key_exists ( '_submit_check', $_POST ) ) { if ( $_POST['full_name'] != '' && $_POST['email'] != '' && $_POST['username'] != '' && $_POST['password'] != '' && $_POST['password'] == $_POST['password_confirmed'] && $_POST['country'] != '' && $_POST['user_code'] != '' && valid_email ( $_POST['email'] ) == TRUE ) { if ( ! checkUnique ( 'Username', $_POST['username'] ) ) { $error = 'Username already taken. Please try again!'; } elseif ( ! checkUnique ( 'Email', $_POST['email'] ) ) { $error = 'The email you used is associated with another user. Please try again or use the "forgot password" feature!'; } elseif (strcmp(md5($_POST['user_code']),$_SESSION['ckey'])) { die("Invalid code entered. Please enter the correct code as shown in the Image"); } else { $query = $db->query ( "INSERT INTO " . DBPREFIX . "users (`full_name` , `Email` , `Username` , `Password` , `Country` , `date_registered` , `Random_key`) VALUES (" . $db->qstr ( $_POST['username'] ) . ", " . $db->qstr ( md5 ( $_POST['password'] ) ).", '" . time () . "', " . $db->qstr ( $_POST['email'] ) . ", '" . random_string ( 'alnum', 32 ) . "')" ); $getUser = "SELECT ID, Username, Email, Random_key FROM " . DBPREFIX . "users WHERE Username = " . $db->qstr ( $_POST['username'] ) . ""; if ( $db->RecordCount ( $getUser ) == 1 ) { $row = $db->getRow ( $getUser ); $subject = "Activation email from " . DOMAIN_NAME; $message = "Dear ".$row->Username.", this is your activation link to join MyVee. In order to confirm your membership please click on the following link: <a href=\"" . APPLICATION_URL . "confirm.php?ID=" . $row->ID . "&key=" . $row->Random_key . "\">" . APPLICATION_URL . "confirm.php?ID=" . $row->ID . "&key=" . $row->Random_key . "</a> <br /><br />Thank you for joining MyVee"; if ( send_email ( $subject, $row->Email, $message ) ) { $msg = 'Account registered. Please check your email for details on how to activate it.'; } else { $error = 'I managed to register your membership but failed to send the validation email. Please contact the admin at ' . ADMIN_EMAIL; } } else { $error = 'User not found. Please contact the admin at ' . ADMIN_EMAIL; } } } else { $error = 'There was an error in your data. Please make sure you filled in all the required data, you provided a valid email address and that the password fields match one another.'; } } ?> <title>MyVee!</title> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <link href="Style2.css" rel="stylesheet" type="text/css"> <div id="wrapper"> <div id="Layer4"> <div style="color:WHITE;"> <script type="text/javascript"> var d=new Date() var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") document.write(weekday[d.getDay()] + " ") document.write(d.getDate() + ". ") document.write(monthname[d.getMonth()] + " ") document.write(d.getFullYear()) </script> </div></div> <div id="Layer2"> <div id="Layer9">There are some outgoing errors with this form which will be fixed in time. It works though, you can register no problem. Sorry for any inconvenience.</div> <div id="Layer10"> <p>Already got a login? go back to the <a href="index.php">homepage</a> and login! </p> </div> </div> <div id="Layer1"></div> <div id="Layer3"> <div id="log"> <?php if ( isset ( $error ) ) { echo ' <p class="error">' . $error . '</p>' . "\n"; } ?> <?php if ( isset ( $msg ) ) { echo ' <p class="msg">' . $msg . '</p>' . "\n"; } else {//if we have a message we don't need this form again.?> </div> <form name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <input type="hidden" name="_submit_check" value="1"/> <br> Name:<br> <input name="full_name" type="text" id="full_name" value="<?php if(isset($_POST['username'])){echo $_POST['username'];}?>" size="32"> Ex. John Blooper <p>Email:<br> <input name="email" type="text" id="email" value="<?php if(isset($_POST['email'])){echo $_POST['email'];}?>" size="32"> Ex. johnB@domain.com<br> <br> <label>Username:<br> <input name="username" type="text" id="username" size="32" maxlength="40"> </label> Ex. JBlooper </p> <p>Password:<br> <input name="password" type="password" id="password" size="32" maxlength="40"> Atleast 5 characters</p> <p>Retype Password:<br> <input name="password_confirmed" type="password" id="password_confirmed" size="32"> </p> <p>Country:<br> <select name="country" id="select8"> <option value="Afghanistan">Afghanistan</option> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option> <option value="Andorra">Andorra</option> <option value="Anguila">Anguila</option> <option value="Antarctica">Antarctica</option> <option value="Antigua and Barbuda">Antigua and Barbuda</option> <option value="Argentina">Argentina</option> <option value="Armenia ">Armenia </option> <option value="Aruba">Aruba</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Azerbaidjan">Azerbaidjan</option> <option value="Bahamas">Bahamas</option> <option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option> <option value="Barbados">Barbados</option> <option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option> <option value="Belize">Belize</option> <option value="Bermuda">Bermuda</option> <option value="Bhutan">Bhutan</option> <option value="Bolivia">Bolivia</option> <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option> <option value="Brazil">Brazil</option> <option value="Brunei">Brunei</option> <option value="Bulgaria">Bulgaria</option> <option value="Cambodia">Cambodia</option> <option value="Canada">Canada</option> <option value="Cape Verde">Cape Verde</option> <option value="Cayman Islands">Cayman Islands</option> <option value="Chile">Chile</option> <option value="China">China</option> <option value="Christmans Islands">Christmans Islands</option> <option value="Cocos Island">Cocos Island</option> <option value="Colombia">Colombia</option> <option value="Cook Islands">Cook Islands</option> <option value="Costa Rica">Costa Rica</option> <option value="Croatia">Croatia</option> <option value="Cuba">Cuba</option> <option value="Cyprus">Cyprus</option> <option value="Czech Republic">Czech Republic</option> <option value="Denmark">Denmark</option> <option value="Dominica">Dominica</option> <option value="Dominican Republic">Dominican Republic</option> <option value="Ecuador">Ecuador</option> <option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option> <option value="Estonia">Estonia</option> <option value="Falkland Islands">Falkland Islands</option> <option value="Faroe Islands">Faroe Islands</option> <option value="Fiji">Fiji</option> <option value="Finland">Finland</option> <option value="France">France</option> <option value="French Guyana">French Guyana</option> <option value="French Polynesia">French Polynesia</option> <option value="Gabon">Gabon</option> <option value="Germany">Germany</option> <option value="Gibraltar">Gibraltar</option> <option value="Georgia">Georgia</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Grenada">Grenada</option> <option value="Guadeloupe">Guadeloupe</option> <option value="Guatemala">Guatemala</option> <option value="Guinea-Bissau">Guinea-Bissau</option> <option value="Guinea">Guinea</option> <option value="Haiti">Haiti</option> <option value="Honduras">Honduras</option> <option value="Hong Kong">Hong Kong</option> <option value="Hungary">Hungary</option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Indonesia">Indonesia</option> <option value="Ireland">Ireland</option> <option value="Israel">Israel</option> <option value="Italy">Italy</option> <option value="Jamaica">Jamaica</option> <option value="Japan">Japan</option> <option value="Jordan">Jordan</option> <option value="Kazakhstan">Kazakhstan</option> <option value="Kenya">Kenya</option> <option value="Kiribati ">Kiribati </option> <option value="Kuwait">Kuwait</option> <option value="Kyrgyzstan">Kyrgyzstan</option> <option value="Lao People's Democratic Republic">Lao People's Democratic Republic</option> <option value="Latvia">Latvia</option> <option value="Lebanon">Lebanon</option> <option value="Liechtenstein">Liechtenstein</option> <option value="Lithuania">Lithuania</option> <option value="Luxembourg">Luxembourg</option> <option value="Macedonia">Macedonia</option> <option value="Madagascar">Madagascar</option> <option value="Malawi">Malawi</option> <option value="Malaysia ">Malaysia </option> <option value="Maldives">Maldives</option> <option value="Mali">Mali</option> <option value="Malta">Malta</option> <option value="Marocco">Marocco</option> <option value="Marshall Islands">Marshall Islands</option> <option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option> <option value="Mexico">Mexico</option> <option value="Micronesia">Micronesia</option> <option value="Moldavia">Moldavia</option> <option value="Monaco">Monaco</option> <option value="Mongolia">Mongolia</option> <option value="Myanmar">Myanmar</option> <option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option> <option value="Netherlands Antilles">Netherlands Antilles</option> <option value="Netherlands">Netherlands</option> <option value="New Zealand">New Zealand</option> <option value="Niue">Niue</option> <option value="North Korea">North Korea</option> <option value="Norway">Norway</option> <option value="Oman">Oman</option> <option value="Pakistan">Pakistan</option> <option value="Palau">Palau</option> <option value="Panama">Panama</option> <option value="Papua New Guinea">Papua New Guinea</option> <option value="Paraguay">Paraguay</option> <option value="Peru ">Peru </option> <option value="Philippines">Philippines</option> <option value="Poland">Poland</option> <option value="Portugal ">Portugal </option> <option value="Puerto Rico">Puerto Rico</option> <option value="Qatar">Qatar</option> <option value="Republic of Korea Reunion">Republic of Korea Reunion</option> <option value="Romania">Romania</option> <option value="Russia">Russia</option> <option value="Saint Helena">Saint Helena</option> <option value="Saint kitts and nevis">Saint kitts and nevis</option> <option value="Saint Lucia">Saint Lucia</option> <option value="Samoa">Samoa</option> <option value="San Marino">San Marino</option> <option value="Saudi Arabia">Saudi Arabia</option> <option value="Seychelles">Seychelles</option> <option value="Singapore">Singapore</option> <option value="Slovakia">Slovakia</option> <option value="Slovenia">Slovenia</option> <option value="Solomon Islands">Solomon Islands</option> <option value="South Africa">South Africa</option> <option value="Spain">Spain</option> <option value="Sri Lanka">Sri Lanka</option> <option value="St.Pierre and Miquelon">St.Pierre and Miquelon</option> <option value="St.Vincent and the Grenadines">St.Vincent and the Grenadines</option> <option value="Sweden">Sweden</option> <option value="Switzerland">Switzerland</option> <option value="Syria">Syria</option> <option value="Taiwan ">Taiwan </option> <option value="Tajikistan">Tajikistan</option> <option value="Thailand">Thailand</option> <option value="Trinidad and Tobago">Trinidad and Tobago</option> <option value="Turkey">Turkey</option> <option value="Turkmenistan">Turkmenistan</option> <option value="Turks and Caicos Islands">Turks and Caicos Islands</option> <option value="Ukraine">Ukraine</option> <option value="UAE">UAE</option> <option value="UK" selected>UK</option> <option value="USA">USA</option> <option value="Uruguay">Uruguay</option> <option value="Uzbekistan">Uzbekistan</option> <option value="Vanuatu">Vanuatu</option> <option value="Vatican City">Vatican City</option> <option value="Vietnam">Vietnam</option> <option value="Virgin Islands (GB)">Virgin Islands (GB)</option> <option value="Virgin Islands (U.S.) ">Virgin Islands (U.S.) </option> <option value="Wallis and Futuna Islands">Wallis and Futuna Islands</option> <option value="Yemen">Yemen</option> <option value="Yugoslavia">Yugoslavia</option> </select> </p> <p> <input name="user_code" type="text" size="10"> <img src="pngimg.php" align="middle"> </p> <p align="center"> <input type="submit" name="Submit" value="Register"> </p> </form> <? } ?> </div> </div> This is my captcha image code <?php session_start(); header ("Content-type: image/png"); $rno = rand(1000,99999); $_SESSION['ckey'] = md5($rno); $img_handle = imageCreateFromPNG("bg1.PNG"); $color = ImageColorAllocate ($img_handle, 0, 0, 0); ImageString ($img_handle, 5, 20, 13, $rno, $color); ImagePng ($img_handle); ImageDestroy ($img_handle); ?> This is my css (I doubt it's needed but might be) /* CSS Document */ div#wrapper { margin-left: auto; margin-right: auto; width: 800px; // Whatever width you want } Layer1 { border: 2px solid #000000; } #Layer1 { border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-left-color: #000000; } #Layer1 { position:absolute; width:801px; height:41px; z-index:1; left: 225px; top: 0px; background-color: #FFFFFF; background-image: url(images/Banner.JPG); } #Layer2 { position:absolute; width:800px; height:518px; z-index:2; left: 224px; top: 52px; } #Layer3 { position:absolute; width:341px; height:115px; z-index:3; left: 455px; top: 62px; } #Layer4 { position:absolute; width:129px; height:19px; z-index:4; left: 896px; top: 23px; } #Layer5 { position:absolute; width:326px; height:184px; z-index:1; left: 458px; top: 11px; } #Layer6 { position:absolute; width:126px; height:14px; z-index:2; left: 575px; top: 7px; } #Layer7 { position:absolute; width:326px; height:19px; z-index:5; left: 0px; top: 8px; } #Layer8 { position:absolute; width:326px; height:49px; z-index:2; left: 458px; top: 210px; } #Layer9 { position:absolute; width:200px; height:115px; z-index:1; left: 17px; top: 10px; } #Layer10 { position:absolute; width:200px; height:115px; z-index:2; left: 587px; top: 10px; } .style3 { font-size: 16px; font-weight: bold; } .style1 {font-size: 18px} body {font:normal 0.7em auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;color:#567475;line-height:1.1} body a {font-weight:bold;text-decoration:none;color:#567475;} .input {border: 1px solid #99b3b4;width: 220px;background: #e4ebeb url(../images/input_stripe.gif);font: 11px verdana, sans-serif;color:#443;padding:3px;outline:none;} .input:focus {border:1px solid #567475;background: #e4ebeb;} .submit-btn {width: 54px;height: 20px;background:url(../images/submit.gif) no-repeat;outline: none;vertical-align:top;border:0;margin:5px 0 0 0;float:center} .submit-btn {margin:1px 0 0 0;#} .submit-btn:hover {background: url(../images/submit.gif) no-repeat 0 -20px;} .clear {clear:both} #log {auto auto auto;} #log p {margin:0;padding:4px 0 4px 0;} .error {color:red;margin:0;padding:0;} .msg {color:green;margin:0;padding:0;} Know what the problem is? everything else seems to be fine for now. Thanks if you can help. Quote Link to comment https://forums.phpfreaks.com/topic/151680-captcha-image-not-displaying/ Share on other sites More sharing options...
timmah1 Posted March 30, 2009 Share Posted March 30, 2009 I do believe you need session_start(); on top of your registration form for the captcha to show <?php session_start(); require_once('settings.php'); if ( array_key_exists ( '_submit_check', $_POST ) ) { ....... ?> Quote Link to comment https://forums.phpfreaks.com/topic/151680-captcha-image-not-displaying/#findComment-796537 Share on other sites More sharing options...
corbin Posted March 30, 2009 Share Posted March 30, 2009 All of the image functions are entirely lower case. (ImageString should be imagestring for example). That shouldn't be causing the error though. Have you tried making errors show and then go to the image and look at the errors? ini_set('display_errors', '1'); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/151680-captcha-image-not-displaying/#findComment-796544 Share on other sites More sharing options...
JeanieTallis Posted March 30, 2009 Author Share Posted March 30, 2009 I have put session_start(); in, and that never worked. also, corbin, where do I put that PHP? I tried it in both register and the image code. Nothing seem to appear up about errors. A little image thing shows up for a millisecond, I managed to print screen it. http://i278.photobucket.com/albums/kk87/JeanieTallis/error.png Quote Link to comment https://forums.phpfreaks.com/topic/151680-captcha-image-not-displaying/#findComment-796679 Share on other sites More sharing options...
Yesideez Posted March 30, 2009 Share Posted March 30, 2009 Make this small PHP file: <?php phpinfo(); ?> Upload that and call it - check to make sure you've got GD installed. If you don't, that's the cause of your problem. If you do it's something else. You're calling the captcha image correctly in your form (via HTML's IMG) so I'd say (at a guess) the error would then be in your captcha file. Quote Link to comment https://forums.phpfreaks.com/topic/151680-captcha-image-not-displaying/#findComment-796687 Share on other sites More sharing options...
Yesideez Posted March 30, 2009 Share Posted March 30, 2009 Have you tried accessing "pngimg.php" directly in your browser to see if it works? If it doesn't it very well could give you an error message saying why - something you wouldn't see when calling it within IMG. Quote Link to comment https://forums.phpfreaks.com/topic/151680-captcha-image-not-displaying/#findComment-796688 Share on other sites More sharing options...
JeanieTallis Posted March 30, 2009 Author Share Posted March 30, 2009 Intelligent Yesideez. It shows an error http://myvee.co.uk/pngimg.php Thats all it tells me. What is GD and how would I call it too. Quote Link to comment https://forums.phpfreaks.com/topic/151680-captcha-image-not-displaying/#findComment-796689 Share on other sites More sharing options...
Yesideez Posted March 30, 2009 Share Posted March 30, 2009 GD is just a library of graphic functions. Without it you can't use the image functions you're using in "pngimg.php" What is the error message you get? Quote Link to comment https://forums.phpfreaks.com/topic/151680-captcha-image-not-displaying/#findComment-796690 Share on other sites More sharing options...
JeanieTallis Posted March 30, 2009 Author Share Posted March 30, 2009 I solved the problem, where it says 'BG1' I never uploaded that file! thanks for the help though guys, i think some of them points you picked out may of been an error too. Quote Link to comment https://forums.phpfreaks.com/topic/151680-captcha-image-not-displaying/#findComment-796692 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.