<?php
$db = "database";//Your database name
$dbu = "root";//Your database username
$dbp = "";//Your database users' password
$host = "localhost";//MySQL server - usually localhost
$dblink = mysql_connect($host,$dbu,$dbp);
$seldb = mysql_select_db($db);
if(isset($_GET['username'])){
//Lightly sanitize the GET's to prevent SQL injections and possible XSS attacks
$username = strip_tags(mysql_real_escape_string($_GET['username']));
$query = "select * from user where username='$username'";
$result = mysql_query($query) or die("User does not exist") ;
$result2=mysql_fetch_array($result);
if($result2)
{
session_start();
$_SESSION['username']=$username;
echo "$result2[id]";
}
else
{
print 'Wrong username or password.';
}
}
else
{
echo "No data input to page.";
}
?>