Jump to content

Captcha Problem


darkfreaks

Recommended Posts

okay i think my if statements are off or something but when i enter the code then press submit it does not submit even if i do enter the code correctly.

 

 

<?php

//Encrypt the posted code field and then compare with the stored key 


include('captcha.php');
include('connect.php');
include('func.php');
$datetime=date("D M j G:i:s T Y"); //date time
$name=$_POST['name'];
$comment=$_POST['comment'];
$email=$_POST['email'];
$submit=$_POST['submit'];

///removing XSS


$comment= RemoveXSS($comment);

if($_POST[comment]=="") {$error[comment]="<br>Please enter a comment";} else {unset($error[comment]);} 

if($_POST[name]=="") {$error[name]="Please enter a name";} else {unset($error[name]);} 

if($_POST[email]=="") {$error[email]="Please enter an email";} else {unset($error[email]);} 




?>
<?php if ($error) { ?>

<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><strong>Test Sign Guestbook </strong></td>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" >
<tr>
<form id="form1" name="form1" method="post" ">
<td>
<table width="400" border="0" cellpadding="3" cellspacing="1">
<tr>
<td width="117">Name</td>
<td width="14">:</td>
<td width="357"><input name="name" type="text" id="name" size="40" /><?php if ($_POST) { echo $error[name];} ?>
</td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="email" type="text" id="email" size="40" /><?php if ($_POST) { echo $error[email];} ?>
</td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">:</td>
<td><textarea name="comment" cols="40" rows="3" id="comment"></textarea><?php if ($_POST) { echo $error[comment];} ?>

</td>
</tr>
<tr>
<td> </td>
<td></td>
<tr><td valign="center"><img src="http://www.wiccan-gathering.com/lilysgraveyard/addons/Guestbook/guestbook.php?t=<?php print time(); ?>" border="0"> </td></tr>
<tr>
<td valign="center">Please Enter The Code:<input name="code" type="text" id="code" size="10" /></td></tr>

<td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td><td></tr>


</table>
</td>
</form>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><strong><a href="http://www.lilysgraveyard.com/index.php?dir=addons/Guestbook&page=viewguestbook">View Guestbook</a> </strong></td>
</tr>

</table>

<?php
session_start(); 
if(isset($_POST['submit'])){
   if(md5($_POST['code']) != $_SESSION['key']) { 
      die("Error: You must enter the code correctly"); 

   }else{
      $sql="INSERT INTO guestbook(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')";
      $result=mysql_query($sql);
   }
}


mysql_close();
}
   


?>



Link to comment
Share on other sites

?php
session_start(); 
if(isset($_POST['submit'])){
   if(md5($_POST['code']) != $_SESSION['key']) { 
      die("Error: You must enter the code correctly"); 

   }else{
      $sql="INSERT INTO guestbook(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')";
      $result=mysql_query($sql);
   }
}


mysql_close();
}
   

 

that is your code you should have an error out of that code because you have session start not on the topmost of the page.

 

try to add an action $_SERVER['PHP_SELF'];

then try to echo those post you have to see if you really get some value for that

Link to comment
Share on other sites

Its sposed to give you a blank page that is security i added to prevent double posting or refreshing the page. but it still should have submitted to the database. but its not. you should be able to go back to view guestbook and view it but its not there.

Link to comment
Share on other sites

try

<?php
session_start(); 
//Encrypt the posted code field and then compare with the stored key 
include('captcha.php');
include('connect.php');
include('func.php');
$datetime=date("D M j G:i:s T Y"); //date time
$name=$_POST['name'];
$comment=$_POST['comment'];
$email=$_POST['email'];
$submit=$_POST['submit'];

///removing XSS


$comment= RemoveXSS($comment);

if($_POST[comment]=="") {$error[comment]="<br>Please enter a comment";} else {unset($error[comment]);} 

if($_POST[name]=="") {$error[name]="Please enter a name";} else {unset($error[name]);} 

if($_POST[email]=="") {$error[email]="Please enter an email";} else {unset($error[email]);} 
if($error) {?>

<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><strong>Test Sign Guestbook </strong></td>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" >
<tr>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF']?>">
<td>
<table width="400" border="0" cellpadding="3" cellspacing="1">
<tr>
<td width="117">Name</td>
<td width="14">:</td>
<td width="357"><input name="name" type="text" id="name" size="40" /><?php if ($_POST) { echo $error[name];} ?>
</td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="email" type="text" id="email" size="40" /><?php if ($_POST) { echo $error[email];} ?>
</td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">:</td>
<td><textarea name="comment" cols="40" rows="3" id="comment"></textarea><?php if ($_POST) { echo $error[comment];} ?>

</td>
</tr>
<tr>
<td> </td>
<td></td>
<tr><td valign="center"><img src="http://www.wiccan-gathering.com/lilysgraveyard/addons/Guestbook/guestbook.php?t=<?php print time(); ?>" border="0"> </td></tr>
<tr>
<td valign="center">Please Enter The Code:<input name="code" type="text" id="code" size="10" /></td></tr>

<td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td><td></tr>


</table>
</td>
</form>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td><strong><a href="http://www.lilysgraveyard.com/index.php?dir=addons/Guestbook&page=viewguestbook">View Guestbook</a> </strong></td>
</tr>

</table>

<?php }
else{
if(isset($_POST['submit'])){
   if(md5($_POST['code']) != $_SESSION['key']) { 
	  die("Error: You must enter the code correctly"); 

   }else{
	  $sql="INSERT INTO guestbook(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')";
	  $result=mysql_query($sql);
   }
}
mysql_close();
}
?>




 

if there minor error kindly fix it  LOL

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.