2012-12-05 74 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”