这些是我的代码 我继续从php端获得未定义的索引,但我想我已经清楚地从表单方面发布了正确的信息,但仍然...... 帮我PLS !!!帮我PLS !!!帮我PLS !!!帮我PLS !!!帮我PLS !!!
<form class="modal-content animate" action="TenantSdb.php">
<div class="container">
<label><b>Username</b></label>
<input type="text" placeholder="Enter Username" name="uname" required>
<label><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="psw" required>
<label><b>Email address</b></label>
<input type="text" placeholder="Enter Email" name="email" required>
<label><b>Contact No</b></label>
<input type="text" placeholder="Enter Contact" name="contact_no" required>
<label><b>Looking for which area</b></label>
<input type="text" placeholder="Enter Area" name="area" required>
<label><b>Gender</b></label>
<input type="text" placeholder="Enter Gender" name="gender" required>
<label><b>Age</b></label>
<input type="text" placeholder="Enter Age" name="age" required>
<label><b>Max Budget</b></label>
<input type="text" placeholder="Enter Budget" name="max_budget" required>
<label><b>Staying With</b></label>
<input type="text" placeholder="Enter Staying with" name="staying_with"
required>
<label><b>Race</b></label>
<input type="text" placeholder="Enter Race" name="race" required>
<button type="submit">Sign Up</button>
<input type="checkbox" checked="checked"> Remember me
</form>
</div>
`
$servername ="localhost";
$dbusername ="root";
$dbpassword ="";
$dbname = "tenantsdb";
$uname = $_POST['uname'];
$psw = $_POST['psw'];
$email = $_POST['email'];
$contact_no = $_POST['contact_no'];
$area = $_POST['area'];
$gender = $_POST['gender'];
$age = $_POST['age'];
$max_budget = $_POST['max_budget'];
$staying_with = $_POST['staying_with'];
$race = $_POST['race'];
$conn = new mysqli($servername, $dbusername,$dbpassword, $dbname);
if ($conn->connect_error)
{
die("Connection failed : " . $conn->connect_error);
}
$sql = "INSERT INTO tenantsignup
(uname,psw,email,contact_no,area,gender,max_budget,staying_with,race) VALUES
('$uname','$psw','$email','$contact_no','$area','$gender','$max_budget',
'$staying_with','$race')";
if($conn->query($sql) === TRUE)
{
echo "Thank you !";
}
else
{
echo "error" . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
i am getting undefined index from
$uname = $_POST['uname'];
$psw = $_POST['psw'];
$email = $_POST['email'];
$contact_no = $_POST['contact_no'];
$area = $_POST['area'];
$gender = $_POST['gender'];
$age = $_POST['age'];
$max_budget = $_POST['max_budget'];
$staying_with = $_POST['staying_with'];
$race = $_POST['race'];
Keep gettting undefined index ^^^ from top, can anyone tell me the problem ?
Please help me, thank you very much
答案 0 :(得分:0)
您已指定属性method='POST'
<form class="modal-content animate" action="TenantSdb.php" method="POST">
默认方法是GET
。因此,如果您未指定方法,则只能使用$_GET
答案 1 :(得分:0)
您必须指定方法,否则默认为 GET 方法。如果您不知道表单中使用的确切方法,则使用$ _REQUEST。 $ _REQUEST可以发布数据以及 GET 数据。它适用于两者。