这是我注册用户的代码。当我点击注册时,不会通过传递变量success来生成头函数中的url。它只显示表单头的上半部分
<?php
if(isset($_GET['success']) && empty($_GET['success'])){
$msg= "You Have Been Registered!";
echo $msg;
}
else{
if(empty($_POST) === false && empty($errors) === true){
$register_data = array(
'user_name' => $_POST['username'],
'password' => $_POST['pass'],
'email' => $_POST['email'],
'mobileno' => $_POST['cell'],
'gen' => $_POST['gen'],
'first_name' => $_POST['firstname'],
'last_name' => $_POST['lastname']
);
register_user($register_data);
echo "redirecting to";
header("location:../../core/Admin/registrationform.php?success");
exit();
}else if(empty($errors) === false ){
echo output_errors($errors);
}
}
?>
</div>
<form method="post" action="">
<label>First Name*</label> <input type="text" name="firstname"/>
<label>Last Name</label> <input type="text" name="lastname"/>
<label>Gender*</label> <input type="text" name="gen"/>
<label>User Name*</label> <input type="text" name="username"/>
<label>Email*</label> <input type="text" name="email"/>
<label>Mobile No* (Must Be Given)</label> <input type="text" name="cell"/>
<label>Password*</label> <input type="text" name="pass"/>
<label>Confirm Password*</label> <input type="text" name="confirmpass"/>
<label>Write The Answer Of* :</label> <input type="text" name="ans"/>
<input id="resetbutton" type="reset" value="Reset Fields"/>
<input id="submitbutton" type="submit" name="submit" value="Sign Up"/>
</form>
答案 0 :(得分:0)
尝试以下代码:
header('Location: url..?success=1');
在标题功能中调用完整网址
或
使用jQuery函数重定向到页面
window.location
http://www.w3schools.com/js/js_window_location.asp
参考此链接
答案 1 :(得分:0)
有诀窍,请在<?php
答案 2 :(得分:0)
永远记住,如果您要重定向到任何页面,那么您不应该在此之前打印任何内容,否则您将收到类似已经发送的标题的错误....只需删除
echo "redirecting to";
标题功能之前的
检查此代码
<?php
if(isset($_GET['success']) && empty($_GET['success'])){
$msg= "You Have Been Registered!";
echo $msg;
}
else{
if(empty($_POST) === false && empty($errors) === true){
$register_data = array(
'user_name' => $_POST['username'],
'password' => $_POST['pass'],
'email' => $_POST['email'],
'mobileno' => $_POST['cell'],
'gen' => $_POST['gen'],
'first_name' => $_POST['firstname'],
'last_name' => $_POST['lastname']
);
register_user($register_data);
header("location:../../core/Admin/registrationform.php?success");
exit();
}else if(empty($errors) === false ){
echo output_errors($errors);
}
}
?>
</div>
<form method="post" action="">
<label>First Name*</label> <input type="text" name="firstname"/>
<label>Last Name</label> <input type="text" name="lastname"/>
<label>Gender*</label> <input type="text" name="gen"/>
<label>User Name*</label> <input type="text" name="username"/>
<label>Email*</label> <input type="text" name="email"/>
<label>Mobile No* (Must Be Given)</label> <input type="text" name="cell"/>
<label>Password*</label> <input type="text" name="pass"/>
<label>Confirm Password*</label> <input type="text" name="confirmpass"/>
<label>Write The Answer Of* :</label> <input type="text" name="ans"/>
<input id="resetbutton" type="reset" value="Reset Fields"/>
<input id="submitbutton" type="submit" name="submit" value="Sign Up"/>
</form>