我目前在这里遇到问题。我有我的html登录页面,一旦我点击登录,它将跳转到php并运行php并从xml中获取数据。但是,当我点击登录时。它只会跳转到PHP而不采取任何行动。
有谁知道代码缺少什么?
Html页面:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<fieldset>
<form method="post" action="login.php">
<p>Email* : <input type="email" name="email" id="email"/></p>
<p>Password* : <input type="password" name="password" id="password"/>
</p>
<div class="buttoninput">
<input type="submit" name="login "value="Login" />
<input type="reset" value="Reset" />
</div>
</form>
</fieldset>
</body>
</html>
Php页面:
<?php
session_start();
if(isset($_POST['login'])) {
$email = $_POST['email'];
$pass = $_POST['password'];
$customerxml = simplexml_load_file('customer.xml');
$email_add = "";
$passw = "";
$customerID = "";
for($i = 0; $i < count($customerxml); $i++){
$email_add = $customerxml->info[$i]->Email;
$passw = $customerxml->info[$i]->Password;
$customerID = $customerxml->info[$i]->CustomerID;
if(($email != $email_add) || ($passw != $pass)){
$message = "wrong email/password";
echo "<script type='text/javascript'>alert('$message');</script>";
}
if(($email == $email_add) && ($passw == $pass)){
$_SESSION['logged_in'] = true;
unset($mydata->info[$i]->Password);
$_SESSION['customer-info'] = json_encode($customerxml->info[$i]);
exit(header("Location: ./bidding.php"));
}
}
}
?>
答案 0 :(得分:0)
<input type="submit" name="login "value="Login" />
name="login "
中有空格删除该空格。因为空格if(isset($_POST['login'])) {
这是失败的
答案 1 :(得分:0)
替换此行
if(isset($_POST['login'])) {
通过
if(isset($_POST['email']) && isset($_POST['password'])) {
在login.php文件中或删除
<input type="submit" name="login "value="Login" />
(name="login "
)