I need help regarding saving sessions into mysql.
Right now I am using php normal sessions for my login system.
Here is my code:
auth.php
<?php
session_start();
include('db.inc.php');
$email=mysql_real_escape_string($_POST['email']);
$pwd=mysql_real_escape_string($_POST['pwd']);
$sql="Select member_id,email,password,nama,type from users where email='$email' and password=md5('$pwd')";
$exec=mysql_query($sql);
$result=mysql_fetch_array($exec);
if ($result['type'] == "member")
{
$_SESSION['nama']=$result['nama'];
$_SESSION['id']=$result['member_id'];
header('location:member.php');
}
else
{
echo 'Anda gagal login';
header('location:index.php');
}
?>
member.php
<?php
session_start();
include('output_fns.php');
if(!$_SESSION['nama'])
{
header('location:index.php');
}
else
{
do_kepala('Member');
echo 'Welcome ' . $_SESSION['nama'];
menu_member();
?>