我嘗試這個在3級不同的操作系統。我正在使用XAMPP,並且使用所有3種操作系統(Mac,Windows,Linux),我在同一個網絡上遇到同樣的問題。POST方法不工作的多個操作系統
形式操作方法是register.php
,和形式,它是自我index.html
。
的錯誤是:
Notice: Undefined index: username in D:\xampp\htdocs\register.php on line 2
Notice: Undefined index: password in D:\xampp\htdocs\register.php on line 3
Notice: Undefined index: email in D:\xampp\htdocs\register.php on line 4
Notice: Undefined index: fname in D:\xampp\htdocs\register.php on line 5
Notice: Undefined index: lname in D:\xampp\htdocs\register.php on line 6
的index.html代碼:
<html>
<h1> Register for Home Server </h1>
<br>
<form method="post" action="register.php">
Username: <input type="text" id="username">
<br>
Password: <input type="password" id="password">
<br>
First Name: <input type="text" id="fname">
<br>
Last Name: <input type="text" id="lname">
<br>
Email: <input type="text" id="email">
<br>
<input type="submit" value="Register">
</form>
</html>
register.php代碼:
<?php
$user = $_POST['username'];
$pass = $_POST['password'];
$email = $_POST['email'];
$fnam = $_POST['fname'];
$lnam = $_POST['lname'];
$id = 1;
$level = 1;
$exp = 100;
$con = mysqli_connect('localhost','root','','members');
$sql = 'INSERT members(id,username,password,fname,lname,email,level,exp) VALUES ($id,$user,$pass,$email,$fnam,$lnam,$email,$level,$exp);';
mysqli_query($con,$sql);
?>
沒有MySQL錯誤,最大後大小8MB,而我自己也嘗試增加,
var_dump($_POST);
die();
我目前運行的是Windows 8
糾正你的SQL查詢與添加「或「用於插入串 – Vineet1982
可能重複的標誌[PHP:‘注意:未定義變量’和‘通知:未定義的索引’](HTTP://計算器。com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – Jocelyn