1

At the moment I create a register "page". Here is the html code of the form

<form class="register_form" method="POST" action="insert.php">
  <label class="label_register">Benutzername*:</label>
  <div class="input_group">
	<input class="input_register" id="register_username" name="username" type="text"/><span class="register_span">-</span>
  </div>
  <label class="label_register">Passwort*:</label>
  <div class="input_group">
	<input class="input_register" id="register_password_1" name="password" type="password"/><span class="register_span">-</span>
  </div>
  <label class="label_register">Passwort wdh.*:</label>
  <div class="input_group"> 
	<input class="input_register" id="register_password_2" name="password2" type="password"/><span class="register_span">-</span>
  </div>
  <label class="label_register">E-Mail Adresse*:</label>
  <div class="input_group">
	<input class="input_register" id="register_email" name="email" type="text"/><span class="register_span">-</span>
  </div>
  
  <button class="button button_register">Jetzt kostenlos registrieren</button>
  <p class="register_hint">
	 * Pflichtfeld
  </p>
</form>

Here is my jquery code

var username_bool = true;
var password_bool = true;
var email_bool = true;
$('.register_form').on('submit', function(){
    if(username_bool == true && password_bool == true && email_bool == true){

        $.ajax({
            type: "POST",
            url: "insert.php",
            data: $(this).serialize(),
            success: function(response){
                console.log(response);
                alert(response);
            },
        });
    }
    else{
        alert("---");
    }
    return false;
});

And here is the php code

<?php
if(isset($_POST["username"]) && isset($_POST["password_1"]) && isset($_POST["email"])){
    echo "response";
}

?>

Now I have sent the form, but the respone is empty. I use Firebug to debugg. What is my mistake? And I made also other mistakes?

Thanks for you help.

2 Answers 2

2

You seem to be checking for a field named password_1

isset($_POST["password_1"])

while it's named password

<input class="input_register" id="register_password_1" name="password" type="password"/><span class="register_span">-</span>

You'll have to make sure the name attribute matches the value you're checking

Sign up to request clarification or add additional context in comments.

Comments

2

The problem i see is you check on isset($_POST["password_1"]) and that is not in the form as you named your password field "password"

<input class="input_register" id="register_password_1" name="password" type="password"/><span class="register_span">-</span>

you need to check using isset($_POST["password"])

1 Comment

Thanks Thanks! That was the mistake

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.