if isset PHP not working?
- by Ellie
Okay, Im trying to set a captcha up, However with this code in, it breaks.
if(isset($_POST["captcha"]))
if($_SESSION["captcha"]==$_POST["captcha"])
When i do it with out it, the page works, but the captcha is letting incorrect submits through.
Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /hermes/waloraweb085/b2027/moo.lutarinet/jointest.php on line 71
<?php
$pagetitle = "Home";
$checkrank = 0;
include ($_SERVER['DOCUMENT_ROOT'].'/header.inc.php');
ECHO <<<END
<br><br>
<b><center><i><u>DO NOT</u> USE YOUR NEOPETS PASSWORD OR PIN NUMBER!!!</b></i></center>
<p>
?>
<?php session_start() ?>
<center><P><FORM ACTION="join.pro.php" enctype="multipart/form-data" METHOD=POST>
<table width="393" height="188" border="0" cellpadding="0" cellspacing="0">
<td width="150">Username</td>
<td width="243"><input type=text name="name" value="" size=32 maxlength=15></td>
</tr>
<tr>
<td>Password</td>
<td><input type=password name="pass1" VALUE="" maxlength=15></td>
</tr>
<tr>
<td>Confirm Password</td>
<td><input type=password name="pass2" VALUE="" size=32 maxlength=15></td>
</tr>
<tr>
<td>Security Code (4 Diget Number)</td>
<td><input type=password name="security" VALUE="" size=32 maxlength=4></td>
</tr>
<tr>
<td>Email Address</td>
<td><INPUT TYPE=text NAME="email" VALUE="" SIZE=32 maxlength=100></td>
</tr>
<tr>
<td height="41" colspan="2" valign="middle"><p><p><center>
By registering an account here you agree to all
of our <A HREF="$baseurl/tos.php">Terms and
Conditions</A>. You can also view our <A HREF="$baseurl/privacy.php">Privacy
Policy</A>.
</center></p></td>
</tr>
<tr><td align="center">CAPTCHA:<br>
(antispam code, 3 black symbols)<br>
<table><tr><td><img src="captcha.php" alt="captcha image"></td><td><input type="text" name="captcha" size="3" maxlength="3"></td></tr></table>
</td></tr>
<td height="27" colspan="2" valign="middle">
<center><input type=submit name=Submit value="Register"></center>
</td>
</table>
</form>
<?php
if(isset($_POST["captcha"]))
if($_SESSION["captcha"]==$_POST["captcha"])
{
//CAPTHCA is valid; proceed the message: save to database, send by e-mail ...
echo 'CAPTHCA is valid; proceed the message';
}
else
{
echo 'CAPTHCA is not valid; ignore submission';
}
?>
<?php
END;
include ($_SERVER['DOCUMENT_ROOT'].'/footer.inc.php');
?>
captcha.php
<?php
session_start();
header("Expires: Mon, 26 Jul 1997 05: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");
function _generateRandom($length=6)
{
$_rand_src = array(
array(48,57) //digits
, array(97,122) //lowercase chars
// , array(65,90) //uppercase chars
);
srand ((double) microtime() * 1000000);
$random_string = "";
for($i=0;$i<$length;$i++){
$i1=rand(0,sizeof($_rand_src)-1);
$random_string .= chr(rand($_rand_src[$i1][0],$_rand_src[$i1][1]));
}
return $random_string;
}
$im = @imagecreatefromjpeg("http://sketchedneo.com/images/sitedesigns/captcha.jpg");
$rand = _generateRandom(3);
$_SESSION['captcha'] = $rand;
ImageString($im, 5, 2, 2, $rand[0]." ".$rand[1]." ".$rand[2]." ", ImageColorAllocate ($im, 0, 0, 0));
$rand = _generateRandom(3);
ImageString($im, 5, 2, 2, " ".$rand[0]." ".$rand[1]." ".$rand[2], ImageColorAllocate ($im, 255, 0, 0));
Header ('Content-type: image/jpeg');
imagejpeg($im,NULL,100);
ImageDestroy($im);
?>
Help please anyone?
Line 71: if(isset($_POST["captcha"]))
Line 72: if($_SESSION["captcha"]==$_POST["captcha"])