Jump to content

Login Errors


Calgaryalberta

Recommended Posts

Yesterday I posted a topic I thought was solved, but it looks as if its not. I have a login script I wrote labeled index.htm, and the checklogin.php will be below the index.htm (checklogin.php) handles the form from index.htm. When trying to login it returns "Wrong username/password" the username/password is not wrong, and the script looks fine to me, any suggestions on how I can fix this? (The username/pw do exist in the db)

 

index.htm

	<table cellSpacing="3" cellPadding="0" width="100%">
	<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername1" type="text" id="myusername1" size="20"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword1" type="password" id="mypassword1" size="20"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</table>

 

checklogin.php

<?php
$host="****"; // Host name 
$username="****"; // Mysql username 
$password="****"; // Mysql password 
$db_name="****"; // Database name 
$tbl_name="****"; // Table name 

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from signup form
$myusername = $_POST['myusername1'];
$mypassword = $_POST['mypassword1'];

$sql = "SELECT * FROM $tbl_name WHERE mysername = '$myusername' AND mypassword = '$mypassword'";
$result = @mysql_query($sql);

// Mysql_num_row is counting table row
$count = @mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count == 1) {
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername1");
session_register("mypassword1");
header("location:login_success.php");

} else {
    echo "Wrong Username or Password";
}
?>

 

Theres no parse errors or anything, its just returning a "Wrong  Username/Password" when the username/password are correct, any tips?

Link to comment
https://forums.phpfreaks.com/topic/92101-login-errors/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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