Jump to content

[SOLVED] getting var unset error! i think its becuase the form action is itsself, HELP!


supergrame

Recommended Posts

here is login.php

 

 

<?php

require_once("db_connect.php");

$username = $_POST['username'];
$password = $_POST['password']; 

$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

$sql="SELECT * FROM users WHERE username='$username' and password='$password'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

if($count==1){

session_register("username");
session_register("password"); 
header('Location: http://www.google.com');

}
else {$login_error="Wrong Username or Password";
}
?>

<html>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<head>
<title>Login.php</title>
</head>
<body>

<div id="login">
<form method="post" action="">
<table>
<tr>
<td colspan="2" align="center"><?php echo "$login_error";?><br>Login or Register!</td>
<td></td>
</tr>
<tr>
<td><label for="username">Username:</label></td>
<td><input type="text" name="username"/></td>
</tr>
<tr>
<td><label for="password">Password:</label></td>
<td><input type="password" name="password"/></td>
</tr>
<tr>
<td><input type="submit" id="submit" value="Login" name="submit" /></td>

</tr>
</table>	
</form>
</div>

</body>
</html>

 

 

 

Here is the error's

Notice: Undefined index: username in C:\wamp\www\public\includes\login.php on line 7

 

Notice: Undefined index: password in C:\wamp\www\public\includes\login.php on line 8

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.