Jump to content

Captcha image not displaying


Recommended Posts

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)



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.';	
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<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()] + " ")
<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 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.?>
<form name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>">
		<input type="hidden" name="_submit_check" value="1"/>
      <input name="full_name" type="text" id="full_name" value="<?php if(isset($_POST['username'])){echo $_POST['username'];}?>" size="32">
      Ex. John Blooper 
      <input name="email" type="text" id="email" value="<?php if(isset($_POST['email'])){echo $_POST['email'];}?>" size="32">
      Ex. johnB@domain.com<br>
  <input name="username" type="text" id="username" size="32" maxlength="40">
Ex. JBlooper  </p>
      <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">
      <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 
          <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>
      <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">
<? } ?>


This is my captcha image code

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 {
left: 225px;
top: 0px;
background-color: #FFFFFF;
background-image: url(images/Banner.JPG);
#Layer2 {
left: 224px;
top: 52px;
#Layer3 {
left: 455px;
top: 62px;
#Layer4 {
left: 896px;
top: 23px;
#Layer5 {
left: 458px;
top: 11px;
#Layer6 {
left: 575px;
top: 7px;
#Layer7 {
left: 0px;
top: 8px;
#Layer8 {
left: 458px;
top: 210px;
#Layer9 {
left: 17px;
top: 10px;
#Layer10 {
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.


Link to comment
Share on other sites

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');


Link to comment
Share on other sites

I have put


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.


Link to comment
Share on other sites

Make this small PHP file:



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.

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.