View Full Version : Login Script Help

12-30-2006, 08:43 PM
I'm going to refer to my thread yesterday (http://www.codingforums.com/showthread.php?t=103956) about developing a registration system for users logging in.

This morning I've been working on a login script.

My login form is as follows:

<form name="form1" method="post" action="checklogin.php">
<p>Please Enter Your
<label>Username: <input name="myusername" type="text" id="myusername" /></label> <label>Email: <input name="myemail" type="text" id="myemail" /></label> <label>Password: <input name="mypassword" type="password" id="mypassword" /></label><input type="submit" name="Submit" value="login" /></form>

My checklogin.php code is:


include 'db.inc.php';
$tbl_name="members"; // Table name

// username and password sent from signup form

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword' and email='$myemail'";

// Mysql_num_row is counting table row
// If result matched $myusername and $mypassword and $myemail, table row must be 1 row

// Register $myusername, $mypassword, $myemail and redirect to file "login_success.php"
else {
echo "Wrong Username or Password";

and finally, my login_success.php is

// Check if session is not registered , redirect back to main page.
// Put this code in first line of web page.

Login Successful

When I click on 'login' I'm getting the error that is being echoed in my checklogin.php code:

"Wrong username and password"

12-31-2006, 12:17 AM
The error message shows if there's no record or more than one record by the credentials that you use. Also try testing with basic chars only: username, password and email with only @ [a-z][A-Z][0-9].

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum