Saturday, 7 September 2013

how to retrieve profile after login using session php

how to retrieve profile after login using session php

I have been having trouble with retrieving profile page after login I have
no Idea how to start I have all the codes for login I don't know how to
use session to display profile information after login please help me I
don't know what else to do
login.php
<?php
include('com.php');
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$email=$_POST['email'];
$password=$_POST['password'];
// To protect MySQL injection (more detail about MySQL injection)
$email = stripslashes($email);
$password = stripslashes($password);
$email = mysql_real_escape_string($email);
$password = mysql_real_escape_string($password);
$sql="SELECT * FROM $tbl_name WHERE email='$email' and
password='$password'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $email and $password, table row must be 1 row
if($count==1){
// Register $email, $password and redirect to file "report.php"
session_register("email");
session_register("password");
header("location:profile.php");
}
else {
echo "Wrong Username or Password";
}
?>

No comments:

Post a Comment