我想在將用戶成功提交到數據庫後將用戶重定向到下一頁。我使用重定向功能,這樣將數據提交到數據庫後重定向到下一頁
<?php
$plan = @$_GET['plan']; // this is from url
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="return Validate();">
<input type="hidden" name="plan" value="<?php echo $plan ?>"/>
Company Name:
<input type="text" name="CompanyName" style="width:230px; height:20px;" /><br /><br />
Company E-mail :
<input type="text" name="CompanyEmail" style="width:230px; height:20px;" /><br /><br />
Company Contact <input type="text" name="CompanyContact" style="width:230px; height:20px;" /><br /><br />
Company Address: <input type="text" name="CompanyAddress" style="width:230px; height:20px;" /><br /><br />
Select Your Registration Type : <br /><br />
Trail: <input type="radio" name="RegistrationType" value="Trail" /><br />
Paid<input type="radio" name="RegistrationType" value="Paid" /><br /><br />
<input type="hidden" name="form_submitted" value="1"/>
<input type="submit" value="REGISTER" name="submit" />
</form>
<?php
include('connect.php');
If (isset($_POST['submit']))
{
$CompanyName = $_POST['CompanyName'];
$CompanyEmail = $_POST['CompanyEmail'];
$CompanyContact = $_POST['CompanyContact'];
$CompanyAddress = $_POST['CompanyAddress'];
$RegistrationType = $_POST['RegistrationType'];
$Plans = $_POST['plan'];
$Status = "Active";
$sql = "INSERT INTO ApplicationRegister (CompanyName, CompanyEmail, CompanyContact, CompanyAddress, RegistrationType, ApplicationPlan, ApplicationStatus, CreatedDate) VALUES ('$CompanyName', '$CompanyEmail', '$CompanyContact', '$CompanyAddress', '$RegistrationType', '$Plans', '$Status', NOW())";
$result = mysql_query($sql) or die(mysql_error());
if($plan == "trail")
{
header("Location: userRegister.php");
}
else
{
header("Location : PaymentGateway.php");
}
}
但它不是任何地方重定向,但其成功提交該數據。請給我建議我要去的地方錯了。
你的SQL是不是很安全,你一定要研究SQL注入,以及如何避免它 – jopke
無論你得到任何錯誤或警告添加error_reporting(E_ALL);在代碼的頂部,並嘗試 –
這段代碼有太多的錯誤。 Sql注入,錯誤suppersion,舊的mysql_ *函數....不要使用@GET。用isset說至少。你不應該吃錯誤,你應該解決它們。 – itachi