View Full Version : Verify two text fields on Submit button click

08-12-2005, 08:52 PM
This should be very simple, but I'm having a bit of trouble.

I have two text boxes, a numberID and a password.
I need to:
1. Verify the numberID is a vaild ID in my table from an SQL query
2. Make sure the password is valid

This is a simple application, but I am VERY new to PHP. I did it in ASP.NET but it's not supported on the server.
Any suggestions, sampel code or articles would be appreciated.

Thanks! I'm diggin' in my PHP books as we speak.

09-15-2005, 09:29 AM
if (isset($_post['textfield']) && isset($_post['textfield2'])){

$userid = $_post['textfield'];
$password = $_post['textfield2'];

$LoginSuccess = 'let_me_in.php';

$LoginFail= 'kick_me_out.php';

mysql_select_db($database_usercheck, $database);
$query_usr = sprintf("SELECT * FROM `user` WHERE `user`.usr_login = '%s' AND `user`.usr_password ='%s'", $userid ,$password);
$usr = mysql_query($query_usr, $database) or die(mysql_error());
$row_usr = mysql_fetch_assoc($usr);
$totalRows_usr = mysql_num_rows($usr);

if ($totalRows_usr > 0){

header("Location: " . $LoginSuccess );


header("Location: " . $LoginFail);



<input type="text" name="textfield" />
<input type="text" name="textfield2" />