我一直在爲我的網站做一個註冊表,但我發現我遇到了麻煩。重定向到索引,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 –