<?php
session_start();
include("conn.php");
$qry=mysql_query("Select * from tblru");
$qry2=mysql_query("Select * from tbladmin");
$credentials=mysql_fetch_array($qry);
$credentials2=mysql_fetch_array($qry2);
if(isset($_POST['login'])){
if($_POST['user']==$credentials["user"]){
if($_POST['pass']==$credentials["pass"]){
$_SESSION['user']=1;
header("location:login.php");
exit();
}
else{
echo "<div style='position:absolute; right:230px; top:220px;'><b>WRONG PASSWORD<br>Re Input PASSWORD</b></div>";
}
}
else if($_POST['user']==$credentials2["useradmin"]){
if($_POST['pass']==$credentials2["pass"]){
$_SESSION['user']=1;
header("location:adminlogin.php");
exit();
}
else{
echo "<div style='position:absolute; right:230px; top:220px;'><b>WRONG PASSWORD<br>Re Input PASSWORD</b></div>";
}
}
else{
echo "<div style='position:absolute; right:230px; top:220px;'><b>WRONG USERNAME<br>Re Input Username</b></div>";
}
}
?>
以下是添加用户的php脚本:
if(isset($_POST['submit'])){
if($_POST['secret']=="060593"){
$user = $_POST['newuser'];
$pass = $_POST['newpass'];
$connect = mysql_connect("localhost","root","");
if($connect){
mysql_select_db("dbreserve",$connect);
$query = "INSERT INTO tblru (user,pass) VALUES (\"" . $user . "\",\"" . $pass . "\")";
if(mysql_query($query)){
echo "<div style='position:absolute; left:615px; top:645px;'><font color='#FFFFFF'><b>User Successfully Created</b></font></div>";
} else {
die ("Failed" . mysql_error());
}
} else {
die ("Failed to connect to mysql: " . mysql_error());
}
}
}
?>
以下是添加注册用户的表单: sjdhgsadlgjasldgijsaldfjskldgsaodjfislahdflisdjf; asdjglisadf不要打扰我输入的内容我只是输入它我可以进行修改 密码: 新用户: 新用户密码:
答案 0 :(得分:0)
<?php
session_start();
include("conn.php");
$qry=mysql_query("Select * from tblru");
$qry2=mysql_query("Select * from tbladmin");
$credentials=mysql_fetch_assoc($qry);
$credentials2=mysql_fetch_assoc($qry2);
while ($row = $credentials) {
$user = $row['user'];
$pass = $row['pass'];
}
if(isset($_POST['login'])){
if($_POST['user']==$user){
if($_POST['pass']==$pass){
$_SESSION['user']=1;
header("location:login.php");
exit();
}
else{
echo "<div style='position:absolute; right:230px; top:220px;'><b>WRONG PASSWORD<br>Re Input PASSWORD</b></div>";
}
}
else if($_POST['user']==$credentials2["useradmin"]){
if($_POST['pass']==$credentials2["pass"]){
$_SESSION['user']=1;
header("location:adminlogin.php");
exit();
}
else{
echo "<div style='position:absolute; right:230px; top:220px;'><b>WRONG PASSWORD<br>Re Input PASSWORD</b></div>";
}
}
else{
echo "<div style='position:absolute; right:230px; top:220px;'><b>WRONG USERNAME<br>Re Input Username</b></div>";
}
}
?>