【发布时间】:2019-03-24 17:56:00
【问题描述】:
此网站适用于一家航运公司,用户在该网站上创建账户并获得 在另一个国家有点虚拟邮箱。当用户创建帐户时,他的信息应该被发送到数据库,并且他应该被重定向到dashboard.html,但是当创建帐户表单被填写并按下提交按钮时,用户应该被重定向到索引.html 但页面不会重定向。并且即使使用php错误报告也没有错误请帮助。
<?php
session_start();
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
error_reporting(E_ALL);
ini_set('display_errors', 1);
if(isset($_POST['submit'])){
//check if variables are empty
if (!empty($firstname) || !empty($lastname) || !empty($email) ||
!empty($confirmemail) ||
!empty($password) || !empty($confirmpassword) ||
!empty($phonenumber) || !empty($address) || !empty($city) ||
!empty($parish) || !empty($trn) )
{
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email= $_POST['email'];
$confirmemail = $_POST['confirmemail'];
$password = $_POST['password'];
$confirmpassword = $_POST['confirmpassword'];
$phonenumber = $_POST['phonenumber'];
$address= $_POST['address'];
$city = $_POST['city'];
$parish = $_POST['parish'];
$trn = $_POST['trn'];
$DB_NAME= "ship2yaad";
$DB_USER="root";
$DB_PASSWORD="";
$DB_HOST= "localhost";
//create connection
$conn= new mysqli("$DB_HOST", "$DB_USER", "$DB_PASSWORD","$DB_NAME");
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'.mysqli_connect_error());
}
$SELECT = "SELECT email From usersdb Where email = ? Limit 1";
$INSERT = "INSERT Into usersdb (firstname , lastname , email
,confirmemail , password , confirmpassword , phonenumber, address,
city, parish ,trn)
values(?,?,?,?,?,?,?,?,?,?,?)";
//Prepare statement
# code...
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result($email);
$stmt->store_result();
$rnum = $stmt->num_rows;
if ($rnum==0) {
$stmt->close();
$stmt = $conn->prepare($INSERT);
// prepare and bind
$stmt->bind_param("ssssssisssi", $firstname, $lastname, $email,
$confirmemail, $password, $confirmpassword ,$phonenumber,
$address, $city, $parish , $trn);
//binds the parameters to the SQL query and tells the database what the
parameters are
$stmt->execute();
$stmt->close();
$conn->close();
header('Location:dashboard.html');
}
?>
the database credentials are correct im 100% sure of it. PLus im not getting a sql connect error.
【问题讨论】:
-
尝试添加空格,例如
header('Location: dashboard.html'); -
我无意中发布了此代码 非常抱歉,真实代码是作为答案发布的
标签: php database html redirect header