
php 登陆问题高手帮解决
<?phpsession_start();require("inc/conn.php");if($_POST['Submit']){$username=$_POST['u...
<?php
session_start();
require("inc/conn.php");
if($_POST['Submit']){
$username=$_POST['username'];
$password=$_POST['password'];
$hao=$_POST['hao'];
$sql = "select count(*) as counts from two_user where username='".$username."' and password='".$password."' and hao='".$hao."'";
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
$counts = $row['counts'];
//判断是否存在此用户
if ($counts == 0)
{
echo "<script language='javascript'> alert('用户名或密码不正确!'); window.location='ceshi.php'; </script>";
exit;
}
else
{
//按编号跳转指定页面
switch ($hao)
{
case 1: {$tmp_alert = "欢迎进入1页面!"; $tmp_location = "yonghu1.php";} break;
case 2: {$tmp_alert = "欢迎进入2页面!"; $tmp_location = "yonghu2.php";} break;
case 3: {$tmp_alert = "欢迎进入3页面!"; $tmp_location = "yonghu3.php";} break;
}
echo "<script language='javascript'> alert('$tmp_alert'); window.location='$tmp_location'; </script>";
exit;
}
?> 展开
session_start();
require("inc/conn.php");
if($_POST['Submit']){
$username=$_POST['username'];
$password=$_POST['password'];
$hao=$_POST['hao'];
$sql = "select count(*) as counts from two_user where username='".$username."' and password='".$password."' and hao='".$hao."'";
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
$counts = $row['counts'];
//判断是否存在此用户
if ($counts == 0)
{
echo "<script language='javascript'> alert('用户名或密码不正确!'); window.location='ceshi.php'; </script>";
exit;
}
else
{
//按编号跳转指定页面
switch ($hao)
{
case 1: {$tmp_alert = "欢迎进入1页面!"; $tmp_location = "yonghu1.php";} break;
case 2: {$tmp_alert = "欢迎进入2页面!"; $tmp_location = "yonghu2.php";} break;
case 3: {$tmp_alert = "欢迎进入3页面!"; $tmp_location = "yonghu3.php";} break;
}
echo "<script language='javascript'> alert('$tmp_alert'); window.location='$tmp_location'; </script>";
exit;
}
?> 展开
展开全部
<?php
session_start();
require("inc/conn.php");
if($_POST['Submit']){
$username=$_POST['username'];
$password=$_POST['password'];
$hao=$_POST['hao'];
//查询用户的时候,只使用名字一个条件
$sql = "select password from two_user where username='$username'";
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
//如果语句错误、或者不存在用户、或者密码不正确
if (!$res || !$row || $row['password' != $password)
{
echo "<script language='javascript'> alert('用户名或密码不正确!'); window.location='ceshi.php'; </script>";
exit;
}
else
{
//按编号跳转指定页面
switch ($hao)
{
case 1: {$tmp_alert = "欢迎进入1页面!"; $tmp_location = "yonghu1.php";} break;
case 2: {$tmp_alert = "欢迎进入2页面!"; $tmp_location = "yonghu2.php";} break;
case 3: {$tmp_alert = "欢迎进入3页面!"; $tmp_location = "yonghu3.php";} break;
}
echo "<script language='javascript'> alert('$tmp_alert'); window.location='$tmp_location'; </script>";
exit;
}
?>
session_start();
require("inc/conn.php");
if($_POST['Submit']){
$username=$_POST['username'];
$password=$_POST['password'];
$hao=$_POST['hao'];
//查询用户的时候,只使用名字一个条件
$sql = "select password from two_user where username='$username'";
$res = mysql_query($sql);
$row = mysql_fetch_array($res);
//如果语句错误、或者不存在用户、或者密码不正确
if (!$res || !$row || $row['password' != $password)
{
echo "<script language='javascript'> alert('用户名或密码不正确!'); window.location='ceshi.php'; </script>";
exit;
}
else
{
//按编号跳转指定页面
switch ($hao)
{
case 1: {$tmp_alert = "欢迎进入1页面!"; $tmp_location = "yonghu1.php";} break;
case 2: {$tmp_alert = "欢迎进入2页面!"; $tmp_location = "yonghu2.php";} break;
case 3: {$tmp_alert = "欢迎进入3页面!"; $tmp_location = "yonghu3.php";} break;
}
echo "<script language='javascript'> alert('$tmp_alert'); window.location='$tmp_location'; </script>";
exit;
}
?>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询