我正在尝试将输入表单放入我的数据库中,但它不起作用。这是我的代码:
<?php
$host="localhost"; // Host name
$username="removed"; // Mysql username
$password="removed"; // Mysql password
$db_name="removed"; // Database name
$tbl_name="input"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$email=$_POST['email'];
// Insert data into mysql
$sql="INSERT INTO $tbl_name(email) VALUES('$email')";
$result=mysql_query($sql);
// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='insert.php'>Back to main page</a>";
}
else {
echo "ERROR";
}
?>
<?php
// close connection
mysql_close();
?>
你好
<form class="form-signin" method="post" action="./php/email2db.php">
<input type="text" name="email" class="input-block-level" placeholder="Email address">
<button class="btn btn-primary" type="submit">Pass The Popcorn</button>
</form>
你能帮我得到它,所以当他们把它拿出来时,它会进入数据库吗?我想要它,但不是这样,请帮忙。