我一直在为我的网站做一个注册表,但我发现我遇到了麻烦。重定向到索引,php
这是我的注册表单代码(PHP文件)
<?php
include("../libraries/Security.php");
include("../includes/utils.inc");
$host = "localhost";
$userSQL = "root";
$pwSQL = "";
$db = "upbyte";
$con = mysqli_connect($host,$userSQL,$pwSQL,$db);
$username = Security::xss_clean($_POST['username']);
$name = Security::xss_clean($_POST['name']);
$email = Security::xss_clean($_POST['email']);
$password = Security::xss_clean($_POST['password']);
$sql = "SELECT email FROM users WHERE email='$email'";
$result = mysqli_query($con,$sql);
$insert = "INSERT INTO users(name,username,password,email) VALUES('$name','$username',md5('$password'),'$email')";
if(isset($_POST['Register'])){
if(mysqli_num_rows($result) == 1){
echo "Sorry...This email already exist..";
}
if(empty($username) && empty($name)&& empty($password)&& empty($email)) {
print('Fill all the fields!');
}else if(mysqli_num_rows($result) == 1){
echo "Sorry...This email already exist..";
}else{
mysqli_query($con,$insert);
echo "Register Completed!";
utils::redirectToUrl("../index.php");
}
} ?>
其所有现在好了,但是当我提交登记表格此重定向我到此: “http://localhost/upbyte/App/index.php”我只是想重定向到:
谢谢。
,但在错误的文件夹中的文件。推测他的'utils :: redirectToUrl'函数执行这个'header()'调用。 – Barmar
@Barmar是我的功能是执行标题:D –