我很难过为什么这段代码不起作用。我正在尝试使用名为“members”的表将数据插入名为“clubresults”的MySQL数据库中。通常这种东西对我来说相当容易,但数据库中没有任何东西出现。显然,现在使用xammpp从localhost运行它。代码如下。
Config.php
<?php
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("clubresults") or die(mysql_error());
?>
RegProcess.php - 主PHP类
<?php
include "config.php";
$Firstname = $_POST['Firstname'];
$Surname = $_POST['Surname'];
$Password = md5($_POST['Password']);
$Email = $_POST['Email'];
$insert = 'INSERT into members(Firstname, Surname, Password, Email) VALUES ("'.$Firstname.'", "'.$Surname.'", "'.Password.'", "'.$Email.'")';
mysql_query($insert);
?>
Register.php - 包含HTML表单
<form action="regprocess.php" method="post">
<table border="0">
<tr><td colspan=2><h1>Register</h1></td></tr> <br>
<tr><td>Firstname:</td><td>
<input type="text" name="Firstname" maxlength="60">
</td></tr>
<tr><td>Surname:</td><td>
<input type="text" name="Surname" maxlength="60">
</td></tr>
<tr><td>Password:</td><td>
<input type="password" name="Password" maxlength="20">
</td></tr>
<tr><td>Email:</td><td>
<input type="text" name="Email" maxlength="50">
</td></tr>
<tr><th colspan=2><input type="submit" name="submit" value="Register">
</form>
答案 0 :(得分:2)
$insert = 'INSERT into members(Firstname, Surname, Password, Email) VALUES ("'.$Firstname.'", "'.$Surname.'", "'.$Password.'", "'.$Email.'")';
^^
你忘了在$
password