2012-12-05 77 views
0

有以下代碼:MySQL的404錯誤

<?php 

if (isset($_POST['submitted'])) { 

$reqwidth = $_POST['reqwidth']; 
$reqside = $_POST['reqside']; 
$reqrad = $_POST['reqrad']; 
$sqlinsert = "INSERT INTO tirelist (width, sidewall, radial) VALUES ('$reqwidth','$reqside', '$reqrad')"; 

if (!mysqli_query($dbcon, $sqlinsert)) { 
die('error inserting new record'); 
} 

$newrecord = "1 record added to database"; 

} 

?> 

<html> 
<head> 
<title>Request Tire Size</title> 
</head> 
<body> 

<h1>Request Tire Size</h1> 

<form method="post" action="insert-data.php"> 
<input type="hidden" name="submitted" value="true" /> 
<fieldset> 
<legend>Request Tire</legend> 
<label>Tire Width: <input type="text" name="reqwidth" /></label> 
<label>Tire Sidewall: <input type="text" name="reqside" /></label> 
<label>Tire Radial: <input type="text" name="reqrad" /></label> 
</fieldset> 
    <br /> 
<input type="submit" value="Send Order Request" /> 
    </form> 

當我點擊發送訂單請求,我得到一個404錯誤。

我發現頁面被稱爲〜HTTP://localhost/index.php P = test2的〜,但是當我點擊它重定向我〜HTTP://localhost/insert-data.php~

一直在努力了幾個小時,想知道什麼我可以做些什麼來解決它

回答

0

變化

<form method="post" action="insert-data.php"> 

擁有的index.php?p = test2的來代替。

+0

請儘可能選擇正確的解決方案。 –

0

在您的表單中,您可以參考insert-data.php。這是否存在?

如果你想提交表單到同一個文件,你可以嘗試使用這個:

<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> 
0

試試這個。 form method =「post」action =「/ insert-data.php」