如果用户类型是求职者则重定向到第一页如果用户类型是雇主则重定向到第二页
If usertype is jobseeker then redirect to 1st page if usertype is employer then redirect to 2nd page
你好,我只想检查用户(正在登录)是否有用户类型 Employer 那么他应该重定向到 my-profile.php 如果用户类型是 Jobseeker 那么他应该重定向到 latest-jobs.php.这是我的代码,如果可以的话请帮助我。
我正在尝试在我的代码中添加一些脚本,但它有一些错误并且无法正常工作。现在它重定向到 latest-jobs.php 到两者(雇主和求职者)。检查我的第二个脚本。
谢谢
<?php
session_start();
include("lib/conn.php");
?>
<?php
$email=$_POST['user'];
$password=$_POST['password'];
if ($email && $password){
$query = "SELECT * FROM register WHERE email = '$email' AND password= '$password' and status = '1'";
$result = mysql_query( $query ) or die ("didn't query");
$num = mysql_num_rows( $result );
if ($num == 1){
$_SESSION['ocer']=$email;
header("Location: my-profile.php");
}
else {
header("Location: index.php?l=1");
}
}
?>
我的第二个剧本
<?php
session_start();
include("lib/conn.php");
?>
<?php
$email=$_POST['user'];
$password=$_POST['password'];
if ($email && $password){
$query = "SELECT * FROM register WHERE email = '$email' AND password= '$password' and status = '1'";
$result = mysql_query( $query ) or die ("didn't query");
$num = mysql_num_rows( $result );
if ($num == 1){
$_SESSION['ocer']=$email;
if ($usertype == "Employer") {
header("Location: my-profile.php");
}
else {
header ("Location: latest-jobs.php");
}
}
else {
header("Location: index.php?l=1");
}
}
?>
我现在找到了解决方案。
<?php
session_start();
include("lib/conn.php");
$email=$_POST['user'];
$password=$_POST['password'];
if ($email && $password)
{
$query = "SELECT * FROM register WHERE email = '".$email."' AND password= '".$password."' and status = '1'";
$result = mysql_query($query) or die ("didn't query". mysql_error());
$num = mysql_num_rows($result);
if($num ==1){
$data = mysql_fetch_array($result);
if($data['usertype'] == 'Employer')
{
$_SESSION['ocer'] = $email;
header("Location: my-profile.php");
}
else if($data['usertype'] == 'Jobseeker')
{
$_SESSION['ocer'] = $email;
header("Location: latest-jobs.php");
}
}
else{
header("Location: index.php?l=1");
}
}
?>
你好,我只想检查用户(正在登录)是否有用户类型 Employer 那么他应该重定向到 my-profile.php 如果用户类型是 Jobseeker 那么他应该重定向到 latest-jobs.php.这是我的代码,如果可以的话请帮助我。
我正在尝试在我的代码中添加一些脚本,但它有一些错误并且无法正常工作。现在它重定向到 latest-jobs.php 到两者(雇主和求职者)。检查我的第二个脚本。
谢谢
<?php
session_start();
include("lib/conn.php");
?>
<?php
$email=$_POST['user'];
$password=$_POST['password'];
if ($email && $password){
$query = "SELECT * FROM register WHERE email = '$email' AND password= '$password' and status = '1'";
$result = mysql_query( $query ) or die ("didn't query");
$num = mysql_num_rows( $result );
if ($num == 1){
$_SESSION['ocer']=$email;
header("Location: my-profile.php");
}
else {
header("Location: index.php?l=1");
}
}
?>
我的第二个剧本
<?php
session_start();
include("lib/conn.php");
?>
<?php
$email=$_POST['user'];
$password=$_POST['password'];
if ($email && $password){
$query = "SELECT * FROM register WHERE email = '$email' AND password= '$password' and status = '1'";
$result = mysql_query( $query ) or die ("didn't query");
$num = mysql_num_rows( $result );
if ($num == 1){
$_SESSION['ocer']=$email;
if ($usertype == "Employer") {
header("Location: my-profile.php");
}
else {
header ("Location: latest-jobs.php");
}
}
else {
header("Location: index.php?l=1");
}
}
?>
我现在找到了解决方案。
<?php
session_start();
include("lib/conn.php");
$email=$_POST['user'];
$password=$_POST['password'];
if ($email && $password)
{
$query = "SELECT * FROM register WHERE email = '".$email."' AND password= '".$password."' and status = '1'";
$result = mysql_query($query) or die ("didn't query". mysql_error());
$num = mysql_num_rows($result);
if($num ==1){
$data = mysql_fetch_array($result);
if($data['usertype'] == 'Employer')
{
$_SESSION['ocer'] = $email;
header("Location: my-profile.php");
}
else if($data['usertype'] == 'Jobseeker')
{
$_SESSION['ocer'] = $email;
header("Location: latest-jobs.php");
}
}
else{
header("Location: index.php?l=1");
}
}
?>