contra10 Posted February 22, 2009 Share Posted February 22, 2009 i'm trying to check if my user has entered the same answer as the answer for security question <?php if (isset($_POST['submit'])) { mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); //This makes sure they did not leave any fields blank if (!$_POST['a'] | !$_POST['pass'] | !$_POST['pass2']) { die('You did not complete all of the required fields'); } // this makes sure both passwords entered match if ($_POST['a'] != $secreta) { die("Your answer did not match. Please <a href='http://localhost/validation/renew.php?id=$ida'>try again! </a> "); } // this makes sure both passwords entered match if ($_POST['pass'] != $_POST['pass2']) { die('Your passwords did not match. '); } // here we encrypt the password and add slashes if needed $_POST['pass'] = encrypt($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['username'] = addslashes($_POST['username']); } $pass = mysql_real_escape_string($_POST['pass']); // now we insert it into the database $insert = "UPDATE `users` SET `password` = '$pass' WHERE `username`='$username'"; $add_update = mysql_query($insert); ?> You can now <a href="http://localhost/">login</a> <?php } else { ?> You are almost finish renewing your password<br> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Please answer your question?<br><?php echo "$secretq $secreta";?><br> Answer:<br> <input type="a" name="a" maxlength="60" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"><br> Username:<br> <input type="text" name="username" maxlength="60" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"><br> New Password:<br> <input type="password" name="pass" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"><br> Confirm Password:<br> <input type="password" name="pass2" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"><br> <input type="submit" name="submit" value="Update"/> </form> <?php } ?> i keep getting the die statement at this point <>php // this makes sure both passwords entered match if ($_POST['a'] != $secreta) { die("Your answer did not match. Please <a href='http://localhost/validation/renew.php?id=$ida'>try again! </a> "); } ?> but i did the query and its getting answer and what i enter in the form is the same Link to comment https://forums.phpfreaks.com/topic/146412-matching-words-from-post-and-query/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.