我在Windows 10上使用server @ localhost运行xampp Apache服务器。 PHP代码不起作用,似乎是什么问题?
PS我正在学习php,任何帮助将不胜感激
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<TITLE>Welcome</TITLE>
</head>
<body>
<form action="" method=POST>
<div>
<strong>Username:</strong><input type="text" name="username" value=""><br/>
<strong>Password:</strong><input type="password" name="password" valuse=""><br/>
<input type="submit" name="submit" value="Submit"><br/>
</div>
</forum>
<?php
session_start();
echo "Hello world!";
include('sql_connect.db.php');
if(isset($_POST[submit])){
$uname=$_POST['username']
$pass=$_POST['password']
}
$result = mysql_query("SELECT * FROM users WHERE username=$uname")
$row=mysql_fetch_array($result);
$flag=0
if($row)
$usp=$row['password']
if (pass==usp){
$_SESSION['login_user'] = $uname;
header("location: success.php");
}else {
$error = "Your Login Name or Password is invalid";
}
?>
</body>
</html>
答案 0 :(得分:1)
<html>
<head>
<TITLE>Welcome</TITLE>
</head>
<body>
<form action="checklogin.php" method="POST">
<div>
<strong>Username:</strong><input type="text" name="username"><br/>
<strong>Password:</strong><input type="password" name="password" ><br/>
<input type="submit" name="submit" value="Submit"><br/>
</div>
</form>
</body>
</html>
<?php
//code for checklogin.php file
session_start();
echo "Hello world!";
include('sql_connect.db.php');
$uname=$_POST['username'];
$pass=$_POST['password'];
$result = mysql_query("SELECT * FROM users WHERE username=$uname");
$row=mysql_fetch_array($result);
$flag=0;
if($row)
$usp=$row['password'];
if (pass==usp){
$_SESSION['login_user'] = $uname;
header("location: success.php");
}else {
$error = "Your Login Name or Password is invalid";
}
?>