darkfreaks Posted August 30, 2007 Share Posted August 30, 2007 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(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/ Share on other sites More sharing options...
Ken2k7 Posted August 30, 2007 Share Posted August 30, 2007 Replace if(isset($_POST['submit'])){ With if ($_POST['Submit']){ Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-337994 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Author Share Posted August 30, 2007 it wont submit? i replaced the code. Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-337998 Share on other sites More sharing options...
Ken2k7 Posted August 30, 2007 Share Posted August 30, 2007 Hmm I don't know. It worked for me. Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338006 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Author Share Posted August 30, 2007 it submitted i went back to my viewguestbook page and it wasnt there. Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338010 Share on other sites More sharing options...
teng84 Posted August 30, 2007 Share Posted August 30, 2007 <form id="form1" name="form1" method="post" "> that is your form where is the action there???? Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338017 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Author Share Posted August 30, 2007 there is no "action" im using the post method Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338020 Share on other sites More sharing options...
teng84 Posted August 30, 2007 Share Posted August 30, 2007 there is no "action" im using the post method I believe you have to tell to your script where should this action go to be process maybe you can use php self or the file name of your php you want to do this action Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338022 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Author Share Posted August 30, 2007 no i dont? it worked fine before. the code got mucked up somehow. Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338023 Share on other sites More sharing options...
teng84 Posted August 30, 2007 Share Posted August 30, 2007 i dont use any thing like captcha that your using but i really think you need to add a form action can you try it and tell us what happen Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338025 Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 If there is no action the default is itself. What do you mean by it won't submit? When you click the button nothing at all happens, or when you click it the page reloads, what? Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338026 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Author Share Posted August 30, 2007 when i enter the code and hit submit for security reasons it loads a bank page so you cant double post. which i think is cool. anyway i linked it back to the viewguestbook.php page and there is no new post. Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338033 Share on other sites More sharing options...
teng84 Posted August 30, 2007 Share Posted August 30, 2007 lol what link? if your saying that you hit the link to get back on that page then the post data will be no longer present on that page thats normal. whats the prob? Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338038 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Author Share Posted August 30, 2007 it is sposed to submit to the database if correct and its not? Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338041 Share on other sites More sharing options...
teng84 Posted August 30, 2007 Share Posted August 30, 2007 ?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 Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338044 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Author Share Posted August 30, 2007 nothing changed i added session_start; at the top and also put action="<?php $_SERVER['PHP_SELF']; ?>" none of which worked Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338049 Share on other sites More sharing options...
teng84 Posted August 30, 2007 Share Posted August 30, 2007 its really confusing first you should receive an error on that session declaration before ? are you sure you have php installed Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338064 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Author Share Posted August 30, 2007 yes i have the latest version of PHP installed. seee for yourself http://www.lilysgraveyard.com/index.php?dir=addons/Guestbook&page=guestbook Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338065 Share on other sites More sharing options...
teng84 Posted August 30, 2007 Share Posted August 30, 2007 so you want the form stay? then i guess you have to check this or reformat that part <?php if ($error) { ?> Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338066 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Author Share Posted August 30, 2007 nnonono that part is fine if i remove that the errors wont work Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338068 Share on other sites More sharing options...
teng84 Posted August 30, 2007 Share Posted August 30, 2007 ok I click on the submit button and it gives me a blank page now what do you want to happen? Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338069 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Author Share Posted August 30, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338071 Share on other sites More sharing options...
teng84 Posted August 30, 2007 Share Posted August 30, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338076 Share on other sites More sharing options...
darkfreaks Posted August 30, 2007 Author Share Posted August 30, 2007 somethings still horribly wrong ??? Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338080 Share on other sites More sharing options...
teng84 Posted August 30, 2007 Share Posted August 30, 2007 whats wrong ? Quote Link to comment https://forums.phpfreaks.com/topic/67362-captcha-problem/#findComment-338081 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.