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
只需練習。這不是任何類型的生產應用程序。 –