Jump to content

[SOLVED] matching words from post and query


contra10

Recommended Posts

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