我有以下代码,表单用于提交。
正如您所看到的,在我的代码中,我有一个页面重定向,具体取决于表单中变量的内容将取决于它重定向到哪个页面。
我在不同的Apache服务器上运行它并且运行正常。我已经更改了webhosts,现在我在header函数
之前得到了关于头文件的错误Page - submission.php:
<?php
// session_start();
$_SESSION['name'] = $_POST['name'];
$_SESSION['address'] = $_POST['address'];
$_SESSION['phone'] = $_POST['phone'];
$_SESSION['email'] = $_POST['email'];
$_SESSION['c-rail'] = $_POST['c-rail'];
$_SESSION['date'] = $_POST['date'];
$_SESSION['stallType'] = $_POST['stallType'];
$_SESSION['bizName'] = $_POST['bizName'];
$_SESSION['insurance'] = $_POST['insurance'];
$_SESSION['goodyBag'] = $_POST['goodyBag'];
$_SESSION['whereHeard'] = $_POST['whereHeard'];
$_SESSION['whereHeard-Other'] = $_POST['whereHeard-Other'];
include("lib/connection.php");
require("lib/sendemail.php");
require("lib/class.phpmailer.php");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$name = mysqli_real_escape_string($link, $_POST['name']);
$address = mysqli_real_escape_string($link, $_POST['address']);
$telephone = mysqli_real_escape_string($link, $_POST['phone']);
$email = mysqli_real_escape_string($link, $_POST['email']);
$clothesRail = mysqli_real_escape_string($link, $_POST['c-rail']);
$bookingDate = mysqli_real_escape_string($link, $_POST['date']);
$stallType = mysqli_real_escape_string($link, $_POST['stallType']);
$bizName = mysqli_real_escape_string($link, $_POST['bizName']);
$insurance = mysqli_real_escape_string($link, $_POST['insurance']);
$goodyBag = mysqli_real_escape_string($link, $_POST['goodyBag']);
$wdyhau = mysqli_real_escape_string($link, $_POST['whereHeard']);
$wdyhauOther = mysqli_real_escape_string($link, $_POST['whereHeard-Other']);
print "<pre>". $sql ."</pre>";
// attempt insert query execution
$sql = "INSERT INTO bookings (name, address, telephone, email, clothesRail, bookingDate, stallType, businessName, insurance, goodyBags, wdyhau, wdyhauOther) VALUES ('$name', '$address', '$telephone', '$email', '$clothesRail', '$bookingDate', '$stallType', '$bizName', '$insurance', '$goodyBag', '$wdyhau', '$wdyhauOther')";
if(mysqli_query($link, $sql)){
sendCustomer();
sendMooWoos();
echo "Insert Success!";
if(isset($_POST['stallType']) && ($_POST['stallType']) == "Preloved"){
die("<script>location.href = 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WC5QXWM2JFUSA' </script>);
}
elseif(isset($_POST['stallType']) && ($_POST['stallType']) == "Craft"){
header("refresh:5;url=https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3TXLEU5D4TXMA");
}
elseif(isset($_POST['stallType']) && ($_POST['stallType']) == "Business"){
header("refresh:5;url=https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CA5XNLCLN22JE");
}
else{
echo "ERROR: Could not redirect";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// close connection
mysqli_close($link);
?>