0
无法让我的数据发布到MySQL服务器。寻找额外的眼睛告诉我为什么它不张贴!下面我有testpost.php
,它允许用户在一个姓名和电子邮件进入并邮寄到我welcome.php
页面,然后创建到其设在mysqli_connect.php
PHP查询预成型没有错误,但没有发布到MySQL服务器
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "test";
$conn = new
mysqli($servername,$username,$password,$database);
if($conn->connect_error){
die("Connection failed:" . $conn->connect_error);
}
echo "Connected Sucessfully";
?>
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>
<html>
<body>
<?php
require_once 'mysqli_connect.php';
$name = $_POST['name'];
$email = $_POST['email'];
$query = "INSERT INTO test_table (name,email) VALUES('$name', '$email')";
?>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"];
?>
</body>
</html>
您的代码易受SQL注入攻击,您需要修复此问题。 – Enstage
只需练习。这不是任何类型的生产应用程序。 –