表单帖子未发送到表单操作php页面
我的表单似乎没有将值发送到表单操作页面。我试图将它们设置为variable,而所有变量都作为未定义的变量进行响应。我使用了var_dump($_POST);它说数组中的所有值都是空的。我已经看过我的表格了。我已经在线测试了代码,也在wamp和xampp上测试了代码,结果相同。如果有人能帮助我,我将不胜感激。我已经为此工作了一个星期了。 这是我的表单页面hash.php:表单帖子未发送到表单操作php页面,php,Php,我的表单似乎没有将值发送到表单操作页面。我试图将它们设置为variable,而所有变量都作为未定义的变量进行响应。我使用了var_dump($_POST);它说数组中的所有值都是空的。我已经看过我的表格了。我已经在线测试了代码,也在wamp和xampp上测试了代码,结果相同。如果有人能帮助我,我将不胜感激。我已经为此工作了一个星期了。 这是我的表单页面hash.php: <html> <body> <h2>Modal Signup Form</h2&
<html>
<body>
<h2>Modal Signup Form</h2>
<button onclick="document.getElementById('id01').style.display='block'"
style="width:auto;">Sign Up</button>
<div id="id01" class="modal">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span>
<form action="action.php" class="modal-content" method= "post">
<div class="container">
<h1>Sign Up</h1>
<p>Please fill in this form to create an account.</p>
<hr>
<label for="username"><b>Username</b></label>
<input type="text" placeholder="Check Availability" name="username" required>
<label for="email"><b>Email</b></label>
<input type="text" placeholder="Enter Email" name="email" required>
<label for="phone"><b>Phone</b></label>
<input type="tel" minlength="10" maxlength="10" placeholder="Enter 10 digit Phone number" name="phone">
<label for="psw"><b>Password</b></label> <span id = 'message'> </span>
<input type="password" pattern= "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])(A-Za-z\d$@$!%*?&]{12,}" placeholder="Enter Password" id= "password" name="password" onkeyup='check();' required>
<label for="psw-repeat"><b>Repeat Password</b></label>
<input type="password" pattern= "^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])(A-Za-z\d$@$!%*?&]{12,}" placeholder="Repeat Password" id= "confirm-password" name="confirm-password" onkeyup='check();' required>
<div class="g-recaptcha" data-sitekey="6LeF200UAAAAAF1pKTeBDArjQ18LBh87bi4w1l1N"></div>
<p>By creating an account you agree to our <a href="#" style="color:dodgerblue">Terms & Privacy</a>.</p>
<div class="clearfix">
<button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button>
<button type="submit" value="submit" class="signupbtn">Sign Up</button>
</div>
</div>
</label>
</form>
<script>
var check = function() {
if (document.getElementById('password').value ==
document.getElementById('confirm-password').value) {
document.getElementById('message').style.color = 'green';
document.getElementById('message').innerHTML = 'matching';
} else {
document.getElementById('message').style.color = 'red';
document.getElementById('message').innerHTML = 'not matching';
}
}
</script>
<script>
// Get the modal
var modal = document.getElementById('id01');
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
</body>
</html>
在您实际使用var_dump()之前,您正在覆盖$POST中的所有变量。试着把它移到顶部。我还颠倒了你的作业,所以你没有覆盖它们
var_dump($_POST);
if (isset($_POST['username']))
{
echo "IT IS SET!";
$username = $_POST['username'];
//Reversed around your assignments
$email = $_POST['email'];
$phone =$_POST['phone'];
$password =$_POST['password'] ;
$confirmpassword = $_POST['confirm-password'];
}
var_dump($username);
echo $password;
echo $confirmpassword;
echo $phone;
echo $email;
echo $username;
与其重新发布他们的代码,不如向他们展示正确的方法。我实际上希望他们注意到错误。。。让他们把它逻辑化。我想我可以在上面发表评论,而不是为他们做评论。:)
var_dump($_POST);
if (isset($_POST['username']))
{
echo "IT IS SET!";
$username = $_POST['username'];
//Reversed around your assignments
$email = $_POST['email'];
$phone =$_POST['phone'];
$password =$_POST['password'] ;
$confirmpassword = $_POST['confirm-password'];
}
var_dump($username);
echo $password;
echo $confirmpassword;
echo $phone;
echo $email;
echo $username;