正如标题所示,我试图通过html表单将记录插入到mysql数据库中。使用html表单(MYSQL/PHP)将记录插入到Dbase
下面是该文件的HTML表单部分:Addstudent.html
/div>
<div id="main">
<h2>Add another student?</h2>
<p>Please fill out the requested fields.</p>
<form action="Insertstudent.php" method="post">
StudentId: <input type="text" name="studentid"><br>
Password: <input type="text" name="password"><br>
Dob: <input type="text" name="dob"><br>
Firstname: <input type="text" name="firstname"><br>
Surname: <input type="text" name="surname"><br>
Address: <input type="text" name="address"><br>
Town: <input type="text" name="town"><br>
County: <input type="text" name="county"><br>
Country: <input type="text" name="country"><br>
Postcode: <input type="text" name="postcode"><br>
<input type="Submit">
这里是文件的一部分Insertstudent.php
<?php
// Insert record using this script
session_start();
include("dbconnect.inc");
// If the form has been submitted
if ($_POST[submit]){
// Build an sql statment to insert a new student to the database
$sql="INSERT INTO student values '" . $_SESSION[id] ."' . '$_POST[studentid]'.'$_POST[password]' . '$_POST[dob]' . '$_POST[firstname]' . '$_POST[lastname]' . '$_POST[house]' . '$_POST[county]' . '$_POST[country]' . '$_POST[postcode]')";
$result = mysql_query($sql,$conn);
?>
主要麻烦我有插入脚本 - 我显然做错了,因为我的数据库不更新。
在此先感谢任何回复此问题的人 - 非常感谢。
不正确插入语句分隔值 – AndrewShmig 2011-05-15 16:46:30