Integers
Soon to be Developer!
- Sep 22, 2012
- 119
- 7
Code:
Notice: Undefined index: username in C:\xampp\htdocs\ThisChat\verify.php on line 6
PHP:
<?php
session_start();
include 'config.php';
$username = $_POST['username'];
$password = $_POST['password'];
if(isset($_POST['Submit']))
{
if($username&&$password)
{
$query = mysql_query("SELECT * FROM `users` WHERE `username`='$username'");
$id1 = mysql_query("SELECT `id` FROM `users` WHERE `username`='$username'");
$numrows = mysql_num_rows($query);
while ($row = mysql_fetch_array($id1))
{
$id = $row['id'];
}
if($numrows!=0)
{
while ($row = mysql_fetch_assoc($query))
{
$user = $row['username'];
$pass = $row['password'];
}
if($username==$user&&md5($password)==$pass)
{
$_SESSION['user']=$username;
$_SESSION['user_id']=$id;
header("location: index.php");
}
else
echo "Your password is incorrect, please try again.";
}
else
echo "The user $username does not exist";
}
else
echo "Please enter your username and password.";
}
if($_SESSION['username'])
{
header("location: index.php");
}
?>