config.php
========================
$dbHost = “localhost”;
$dbUser = “root”;
$dbPassword = “”;
$dbName= “hanzala”;
$con = mysql_connect($dbHost, $dbUser, $dbPassword);
mysql_select_db($dbName, $con);
session_start();
// echo “
”; print_r($_SESSION);
exit;
?>
action.php
=======================================================================
include “config.php”;
if(isset($_POST['submit']) &&
$_POST['submit'] == ‘Register’)
{
$name = $_POST['name'];
$password = $_POST['password'];
$city = $_POST['city'];
$state = $_POST['state'];
$sex = $_POST['sex'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$insert = “INSERT INTO test02 SET empName =
‘$name’, empPass = ‘$password’, empCity = ‘$city’, empState = ‘$state’,
empSex = ‘$sex’ empEmail = ‘$email’, empPhone = ‘$phone’”;
$result = mysql_query($insert);
if($result)
{
header(“Location:newpage.php?msg =
Registration Completed”);
exit;
}
}
if(isset($_POST['submit']) &&
$_POST['submit'] == ‘Update’)
{
$name = $_POST['name'];
$password = $_POST['password'];
$city = $_POST['city'];
$state = $_POST['state'];
$sex = $_POST['sex'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$queryupdate = “UPDATE test02 SET empName =
‘$name’, empPass = ‘$password’, empCity = ‘$city’, empState = ‘$state’,
empSex = ‘$sex’, empEmail = ‘$email’, empPhone = ‘$phone’”;
$result = mysql_query($queryupdate);
if($result)
{
header(“Location:newpage.php?msg = Update
Succefully”);
exit;
}
}
if(isset($_POST['submit']) &&
$_POST['submit'] == ‘Login’)
{
$name = $_POST['name'];
$password = $_POST['password'];
$queryLogin = “SELECT * FROM test02 WHERE
empName = ‘$name’ AND empPass = ‘$password’ “;
$resultLogin = mysql_query($queryLogin);
if(mysql_num_rows($resultLogin) > 0)
{
$row = mysql_fetch_assoc($resultLogin);
$_SESSION['empId'] = $row['empId'];
$_SESSION['empName'] = $row['empName'];
header(“Location: log_success.php”);
exit;
}
else
{
header(“Location: login.php?msg=Login
Failed”);
}
}
if(isset($_GET['submit']) &&
$_GET['submit'] == ‘logout’)
{
session_destroy();
header(“Location: login.php”);
}
?>
config.php
========================
$dbHost = “localhost”;
$dbUser = “root”;
$dbPassword = “”;
$dbName= “hanzala”;
$con = mysql_connect($dbHost, $dbUser, $dbPassword);
mysql_select_db($dbName, $con);
session_start();
// echo “
========================
$dbHost = “localhost”;
$dbUser = “root”;
$dbPassword = “”;
$dbName= “hanzala”;
$con = mysql_connect($dbHost, $dbUser, $dbPassword);
mysql_select_db($dbName, $con);
session_start();
// echo “
”; print_r($_SESSION); exit; ?> action.php ======================================================================= include “config.php”; if(isset($_POST['submit']) && $_POST['submit'] == ‘Register’) { $name = $_POST['name']; $password = $_POST['password']; $city = $_POST['city']; $state = $_POST['state']; $sex = $_POST['sex']; $email = $_POST['email']; $phone = $_POST['phone']; $insert = “INSERT INTO test02 SET empName = ‘$name’, empPass = ‘$password’, empCity = ‘$city’, empState = ‘$state’, empSex = ‘$sex’ empEmail = ‘$email’, empPhone = ‘$phone’”; $result = mysql_query($insert); if($result) { header(“Location:newpage.php?msg = Registration Completed”); exit; } } if(isset($_POST['submit']) && $_POST['submit'] == ‘Update’) { $name = $_POST['name']; $password = $_POST['password']; $city = $_POST['city']; $state = $_POST['state']; $sex = $_POST['sex']; $email = $_POST['email']; $phone = $_POST['phone']; $queryupdate = “UPDATE test02 SET empName = ‘$name’, empPass = ‘$password’, empCity = ‘$city’, empState = ‘$state’, empSex = ‘$sex’, empEmail = ‘$email’, empPhone = ‘$phone’”; $result = mysql_query($queryupdate); if($result) { header(“Location:newpage.php?msg = Update Succefully”); exit; } } if(isset($_POST['submit']) && $_POST['submit'] == ‘Login’) { $name = $_POST['name']; $password = $_POST['password']; $queryLogin = “SELECT * FROM test02 WHERE empName = ‘$name’ AND empPass = ‘$password’ “; $resultLogin = mysql_query($queryLogin); if(mysql_num_rows($resultLogin) > 0) { $row = mysql_fetch_assoc($resultLogin); $_SESSION['empId'] = $row['empId']; $_SESSION['empName'] = $row['empName']; header(“Location: log_success.php”); exit; } else { header(“Location: login.php?msg=Login Failed”); } } if(isset($_GET['submit']) && $_GET['submit'] == ‘logout’) { session_destroy(); header(“Location: login.php”); } ?>
No comments:
Post a Comment