Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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