【发布时间】:2017-07-22 18:07:22
【问题描述】:
我一直在学习网页设计。首先,我学会了使用 php 和 mysql 数据库创建一个 html 表单。
表单完美运行。但是每当我点击提交按钮时,它都会显示 Your file was not found 错误。
这是我的 html 代码,
<html>
<head>
<title>Registration Form</title>
</head>
<body>
<link href = "registration.css" type = "text/css" rel = "stylesheet" />
<h2>Fun Quizzes</h2>
<form name = "form1" action="modified.php" method = "post" enctype = "multipart/form-data" >
<div class = "container">
<div class = "form_group">
<label>Questions:</label>
<input type = "text" name = "Questions" value = "" required/>
</div>
<div class = "form_group">
<label>Correct Answer :</label>
<input type = "text" name = "Correct_Answer" value = "" required />
</div>
<div class = "form_group">
<label>wrong - 1 :</label>
<input type = "text" name = "wrong_1 " value = "" required/>
</div>
<div class = "form_group">
<label>wrong - 2:</label>
<input type = "text" name = "wrong_2" value = "" required/>
</div>
<div class = "form_group">
<label>wrong - 3 :</label>
<input type = "text" name = "wrong_3" value = "" required/>
</div>
<div form action="C:\Users\user\Desktop\Students_Profiles\connection.php" method="post">
<label>Submit:</label>
<input type = "submit"/>
</div>
</div>
</form>
</body>
这是我的 php 代码,
<?php
// Grab our POSTed form values
// Note that whatever is enclosed by $_POST[""] matches the form input elements
$Questions = $_POST["Questions"];
$Correct_Answer = $_POST["Correct_Answer"];
$wrong_1 = $_POST["wrong_1"];
$wrong_2 - $_POST["wrong_2"];
$wrong_3 - $_POST["wrong_3"];
// Connect to our DB with mysql_connect(<server>, <username>, <password>)
$sql_connection = mysql_connect("localhost", "root", "");
mysql_select_db("test_series_quizz", $sql_connection);
// Probably should check to make sure the connection was successful
// But I'm too lazy...
$sql = "INSERT INTO history_of_india (
Questions,
Correct_Answer,
wrong_1,
wrong_2,
wrong_3
)
VALUES (
'$Questions',
'$Correct_Answer',
'$wrong_1',
'$wrong_2',
'$wrong_3'
)"
mysql_query($sql, $sql_connection);
mysql_close($sql_connection);
?>
我的sql连接是Localhost,用户名是root,没有密码。任何帮助,将不胜感激。提前致谢。
【问题讨论】:
-
您的 php 页面是否名为 modified.php ?在我看来,您的问题是找不到该文件。确保您在 action 属性或表单中拥有正确的路径和名称。
-
谢谢@PatrickSimard 没有
-
现在我更改了我的 php 文件名 connection.php
-
你的问题呵呵
-
你能告诉我如何使用提交按钮发送数据
标签: php html mysql forms http-post