我正在寫一個腳本,用戶從一個框中選擇一個選項,然後他們單擊提交,他們的選擇被寫入MySQL數據庫。然而,每當我嘗試點擊提交,網址都會從(例如:www.stackoverflow.com/questions到www.stackoverflow.com/questions/unknown)更改。我一直在尋找幾個小時,似乎無法弄清楚爲什麼會發生這種情況。有沒有人有什麼建議可能會導致這種情況?這是當有人點擊提交按鈕時應該運行的腳本。PHP腳本去標題爲「未知」
if($_POST)
{
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_name", $con);
$q1 = $_POST['q1'];
$q2 = $_POST['q2'];
$q3 = $_POST['q3'];
$q4 = $_POST['q4'];
$q5 = $_POST['q5'];
$q6 = $_POST['q6'];
$q7 = $_POST['q7'];
$q7 = $_POST['q7'];
$q8 = $_POST['q8'];
$qf1 = $_POST['qf1'];
$qf2 = $_POST['qf2'];
$qf3 = $_POST['qf3'];
$qf4 = $_POST['qf4'];
$s1 = $_POST['s1'];
$s2 = $_POST['s2'];
$final = $_POST['final'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$q1 = mysql_real_escape_string($q1);
$q2 = mysql_real_escape_string($q2);
$q3 = mysql_real_escape_string($q3);
$q4 = mysql_real_escape_string($q4);
$q5 = mysql_real_escape_string($q5);
$q6 = mysql_real_escape_string($q6);
$q7 = mysql_real_escape_string($q7);
$q8 = mysql_real_escape_string($q8);
$qf1 = mysql_real_escape_string($qf1);
$qf2 = mysql_real_escape_string($qf2);
$qf3 = mysql_real_escape_string($qf3);
$qf4 = mysql_real_escape_string($qf4);
$s1 = mysql_real_escape_string($s1);
$s2 = mysql_real_escape_string($s2);
$final = mysql_real_escape_string($final);
$fname = mysql_real_escape_string($fname);
$lname = mysql_real_escape_string($lname);
$query = "
INSERT INTO `db_name`.`table_name` (`qualifier_1`, `qualifier_2`, `qualifier_3`, `qualifier_4`, `qualifier_5`, `qualifier_6`, `qualifier_7`, `qualifier_8`, `quarter_1`, `quarter_2`, `quarter_3`, `quarter_4`, `semi_1`, `semi_2`, 'final', 'first_name', 'last_name', 'TimeDate') VALUES ('$q1', '$q2', '$q3', '$q4', '$q5', '$q6', '$q7', '$q8', '$qf1', '$qf2', '$qf3', '$qf4', '$s1', '$s2', '$final', '$fname', '$lname', CURRENT_TIMESTAMP);";
mysql_query($query);
echo "<h2>Thank you for your Submission!</h2>";
mysql_close($con);
}
?>
此代碼無一正在更改操作
當你說改變動作
你有一些JavaScript更新你的