Javascript 当用户点击提交按钮时,如何调用两个不同的网页?
我的代码如下所示:Javascript 当用户点击提交按钮时,如何调用两个不同的网页?,javascript,php,html,Javascript,Php,Html,我的代码如下所示: <form action="register.php" method="post"> <input type="text" name="uname"> <input type="submit" > </form> 在register.php文件中,我有一个数据库连接代码。 如果数据库通过register.php文件连接,我需要在同时提交表单后加载另一个html页面 如何做到这一点?注册成功后,只需通过功能将用户重定
<form action="register.php" method="post">
<input type="text" name="uname">
<input type="submit" >
</form>
在register.php文件中,我有一个数据库连接代码。
如果数据库通过register.php文件连接,我需要在同时提交表单后加载另一个html页面
如何做到这一点?注册成功后,只需通过功能将用户重定向到第二页: index.php:
<form action="register.php" method="post">
<input type="text" name="uname">
<input type="submit" >
</form>
success.php:
// Thank the user for registering
或者,您也可以在register.php
本身上处理success
页面
希望这有帮助!:) 在您的
Register.Php中
加上这样的东西
检查Sql结果,如下所示
$sql='select * Tablename where condition'
$result= fetch($sql)
$row=fetch_array($result)asdsad
if($row>0){
header(Location:'connected.php') // whatever your html
}
else {header(Location:"failed.php")//whenever query got no row
}
欢迎来到SO。在我看来,您实际上不需要同时加载2个URL,您需要的是一个if语句,仅当设置了post数据时才执行某些代码
if(!empty($_POST)){
//code to execute when form is submitted
}
else {
//code to execute otherwise
}
如果您确实需要同时向2个URL发出请求,那么您正在寻找AJAX请求
关于设置和最终目标的问题中的更多细节将有助于进一步帮助。使用标题(“位置:其他页面\ url”);在您的post请求之后检查:您不能调用两个页面,但您可以调用第一个页面,而这个页面正在重定向到第二个页面,或者你使用ajax请求我认为这不是很有效,因为你可以直接在浏览器中浏览failed.php或connected.php,而不需要使用cookies来验证。哇@WillCraig你真的愿意评判我吗?我只是觉得有更好的答案,我已经说过了是的,你会的,威尔先生
if(!empty($_POST)){
//code to execute when form is submitted
}
else {
//code to execute otherwise
}