我遇到第二个按钮运行不像第一个按钮的问题。这是我的代码:
<p>
<form method="POST">
<input placeholder="Username" type="text" name="username"><br /><br />
<input placeholder="password" type="password" name="password"><br /><br />
<input value="Login" type="submit" name="log_In">
</form>
</p>
</div>
<?php
if(isset($_POST['log_In'])) {
#$f_name = $_POST['fname'];
#$s_name = $_POST['sname'];
#$stud_Id = $_POST['studId'];
#$uname = $_POST['uname'];
#$pass = $_POST['pass'];
#$rpass = $_POST['rpass'];
#$email = $_POST['email'];
#$remail = $_POST['remail'];
#var_dump($f_name);
header("Location:home.php");
}
?>
</div>
<div align="right">
<div>
<p>
<h2>Sign Up</h2>
</p>
<p>
<form>
<input placeholder="Forename" type="text" name="fname" id="Forename"><br /><br />
<input placeholder="Surname" type="text" name="sname"><br /><br />
<input placeholder="Student Id" type="text" name="studId"><br /><br />
<input placeholder="Username" type="text" name="uname"><br /><br />
<input placeholder="password" type="password" name="pass" min="6" max="32"><br /><br />
<input placeholder="Re-type password" type="password" name="rpass" min="6" max="32"><br /><br />
<input placeholder="Email" type="" name="email"><br /><br />
<input placeholder="Re-type Email" type="remail" name="remail"><br /><br />
<input value="Sign Up" type="submit" name="sign_Up">
</form>
</p>
</div>
<?php
if(isset($_POST['sign_Up'])) {
header("Location:home.php");
}
?>
</div>
“if(isset($ _ POST ['sign_up'])){”没有运行,只是刷新页面并从表单中删除所有项目。
感谢
答案 0 :(得分:1)
默认情况下,<form>
方法是GET。所以if(isset($_POST['sign_Up']))
无法工作。将其更改为if(isset($_GET['sign_Up']))
。
或者将您的第二个表单标记更改为:
<form method="POST">
请记住,在生成HTML内容后不要使用header函数,请将其移至顶部!
必须在通过普通HTML标记,文件中的空行或PHP发送任何实际输出之前调用header()。
如果是这样的话会更好:
<?php
if(isset($_POST['log_In']) || isset($_POST['sign_Up'])) {
header("Location:home.php");
}
?>
<form method="POST">
<input placeholder="Username" type="text" name="username">
<br />
<br />
<input placeholder="password" type="password" name="password">
<br />
<br />
<input value="Login" type="submit" name="log_In">
</form>
<div align="right">
<div>
<p>
<h2>Sign Up</h2>
</p>
<p>
<form method="post">
<input placeholder="Forename" type="text" name="fname" id="Forename">
<br />
<br />
<input placeholder="Surname" type="text" name="sname">
<br />
<br />
<input placeholder="Student Id" type="text" name="studId">
<br />
<br />
<input placeholder="Username" type="text" name="uname">
<br />
<br />
<input placeholder="password" type="password" name="pass" min="6" max="32">
<br />
<br />
<input placeholder="Re-type password" type="password" name="rpass" min="6" max="32">
<br />
<br />
<input placeholder="Email" type="" name="email">
<br />
<br />
<input placeholder="Re-type Email" type="remail" name="remail">
<br />
<br />
<input value="Sign Up" type="submit" name="sign_Up">
</form>
</p>
</div>
</div>
答案 1 :(得分:0)
您忘记添加方法=&#34;发布&#34;
SELECT `chart_rating` . * , SUM( chart_rating.rating_score ) AS total_score, release.release_label
FROM `chart_rating`
INNER JOIN `release` ON `chart_rating`.`rating_release_id` = `release`.`id`
WHERE MATCH (
REPLACE(release.release_label,' ','')
)
AGAINST (
"+UltraMusic"
IN BOOLEAN MODE
)
GROUP BY `rating_release_id`
ORDER BY `total_score` DESC
答案 2 :(得分:0)
以第二种形式你没有定义方法如果没有定义方法它将接受GET方法默认,所以改变你的第二个表格标签
<form action="" method="POST">