Checking textbox against DB field
Posted: Sat Oct 24, 2009 8:08 am
I am trying to check the input of a textbox against the field of the db. however i am having problems with getting the error msg to show.
Now the problem is that i just cant seem to get it to show error if its the wrong pin. and if its the right one it stays on the page which its suppose to redirect. Here is my code for the form
I hope someone can help me out i know I must be forgetting something to let it work.
Thanks
Code: Select all
if(strlen($_POST['cancel'])) { //cancel button
if($_POST['pin'] != $pin) { //if the text box does not match the dbfield
$error=TRUE;
$msg.='<li>You did not enter the security code correctly!</li>'; //show error msg
} else {
$r = mysql_query("delete from Users WHERE pin='".$_POST['pin']."'")or die (mysql_error()); //execute query
Code: Select all
<?php
if($DONE==TRUE) {
?>
<h4 class="left_nav" style="margin-top: 1em;">Account Being Deleted..Please Wait... </h4>
<p>You are now being logged out. Sorry to see you go</p>
<?php
} else {
?>
<?php if($error==TRUE) { echo "<ul><font color=red>$msg</font></ul>"; } ?><form action="termination.php" method="post"><table width="100%">
<tr>
<td width="31%">Security Code : </td>
<td width="69%"><input name="pin" type="text" id="pin" style="width: 200px;" maxlength="20"></td>
</tr>
<tr>
<td colspan="2"><div align="center"><input name="cancel" type="submit" id="cancel" value="Cancel My Account" /></div></td>
</tr>
</table>
</form> <?php } ?> I hope someone can help me out i know I must be forgetting something to let it work.
Thanks