I have a form for people to enter a primary key, kind of like a password. If they enter a correct pass they can edit their info. I need a script that will check to see if the key is already being used. Any ideas.
I just need to check if it's their not insert anything or select it
php mysql question
Moderator: General Moderators
Code: Select all
<?
$confirmkey = mysql_query("SELECT COUNT(*) FROM $db WHERE key='$key'");
if ($confirmkey){
send to next page
} else {
send to error page
}
?>Still having trouble
I entered it in, changed the variables to my info. It won't work correctly, it's going into the if statement no matter what the variable is. The else is not being executed when the key is not in the database
try wrapping the entire thing around an if statement
eg.
and have the form send the data to a different page.
hope it works.
eg.
Code: Select all
<?php
if($submit){
$confirmkey = mysql_query("SELECT COUNT(*) FROM $db_table WHERE key='$key'"); //db query to check for key in tables
if ($confirmkey){
send to next page
} else {
send to error page
} //ends confirmkey if
}//ends submit if
?>and have the form send the data to a different page.
hope it works.