1
好吧,我的注册表单数据没有存储在数据库中。而如果我做$name="Bill";
然后它的存储但$name='name';
不起作用。其次,当文件i click
上register button
它的展示的php代码connect.php.
表单数据没有存储在数据库中
注册码
<body>
<div id="registration">
<h2><b><i>Electronic Montessori Learning</i><b></h2>
<form id="RegisterUserForm" action="connect.php" method="post">
<fieldset>
<p>
<label for="name">Name</label>
<input id="name" name="name" type="text" class="text" value="" />
</p>
<p>
<label for="password">Password</label>
<input id="password" name="password" class="text" type="password" />
</p>
<p>
<button id="registerNew" type="submit">Register</button>
</p>
</fieldset>
</form>
</div>
<body>
现在connect.php代码
<?php
$db=mysql_connect("localhost", "root", "") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("users") or die(mysql_error());
echo "Connected to Database";
if(isset($_POST['Submit'])){
// Storing form values into PHP variables
$name = $_POST['name']; // Since method=”post” in the form
$password = $_POST['password'];
mysql_query("INSERT INTO user_eml(Name, Password) VALUES('$name', '$password') ")
or die(mysql_error());
echo "Data Inserted!";
echo 'Thank you for submitting your details!';
}
?>
然后您的服务器不与PHP配置。 –
**小心!**'mysql_ *'函数[老,不应该再使用](http://bit.ly/phpmsql)。请查看[PDO](http://php.net/pdo)或[MySQLi](http://php.net/msqli),这些更好[MySQL API选项](http:// php。净/手动/ EN/mysqlinfo.api.choosing.php)。 –
'mysql_ *'是不推荐使用的代码。请使用'PDO'或'mysqli_ *'。 – christopher