Simple Login code php development

$con = mysql_connect(“localhost”,”root”,””) or die(“mysql conn. error”);
mysql_select_db(‘databasename’) or die(“mysql conn. error”); // database connection

// login  page code

if(isset($_POST[“Button”]))

{

$aidd  = $_POST[“Id”];  // get textbox value
$apass = $_POST[“pass”]; // get textbox value
$query = “select * from TableName where id =  ‘$aidd’ and Password = ‘$apass'”;  //sql query
$res = mysql_query($query ,$con); //execute query
if(mysql_num_rows($res) == 1)
{
$_SESSION[‘aid’] =  $aidd;
$_SESSION[‘apass’] = $apass;
header(‘Location:login.php’);   //redirect another page
}
else
{
echo “Error : Please Enter Correct password”;    // error message
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s