你好,我有兩臺服務器,一臺帶有表單和mysql數據庫,我把數據插入數據庫。另一臺服務器只有一種表單,我希望將填入表單的數據插入到第一個數據庫服務器中。 如何將seconde服務器的表單安全地插入到數據庫中?兩臺服務器兩個表單和一個數據庫
這是第一個服務器的代碼:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
<link rel="" href="">
</head>
<body>
<script src=""></script>
<form action="reg.php" method="post">
<label>First name: <input type="text" name="firstname"><br>
<label>Last name: <input type="text" name="lastname"><br>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</body>
</html>
<?php
\t if(empty($_POST["firstname"]) OR empty($_POST["lastname"])) {
\t \t header("refresh:5; url=registration.html");
\t \t echo "please fill all the fields.";
\t }
\t else {
\t \t $con=mysqli_connect("localhost","root","","form");
\t \t if(!$con) {
\t \t \t die(" error: ". mysql_error());
\t \t }
\t \t $firstname=$_POST['firstname'];
\t \t $lastname=$_POST['llastname'];
\t \t $sql= "INSERT INTO a_database (id, firstname, lastname,)
\t \t VALUES('DEFAULT','$firstname','$lastname',CURRENT_TIMESTAMP)";
\t \t if(mysqli_query($con,$sql)) {
\t \t \t echo "success";
\t \t }
\t \t else {
\t \t \t echo "Error: " . $sql . "<br>" . mysqli_error($conn);
\t \t }
\t \t
\t }
\t mysqli_close($con);
?>
謝謝你我使用你的soloution – George