I am sending form data through POST, but the corresponding POST variables are not set, and do not.
Also, when I store POST data into local PHP variables, I seem to be unable to use those variables. (Once I resolve the first issue, I have a feeling I will be able to user the variables too.)
My error messages output by the second page (see below) is:
Notice: Undefined variable: postUsername in (...somepath)\scripts\create-member.php on line 10
(Form page) :
<form action="scripts/create-member.php" method="POST">
<input type="text" name"username" value="" placeholder="User Name"> <br />
<input type="password" name"password" value="" placeholder="Password"> <br />
<input type="password" name"passwordConfirm" value="" placeholder="Confirm Password"> <br />
<!-- ?type email or type text -->
<input type="email" name"email" value="" placeholder="Email" autofocus> <br />
<input type="submit" name="submitRegistration" value="Register!">
</form>
(Second page) scripts\create-member.php:
<?php
//!proper way to declare variables obtained from POST.
// Data from form "register.php"
if ( isset($_POST['username']) ) {
$postUsername = $_POST['username'];
}
echo $postUsername; // <-- this is line 10
?>
I've tried using isset() for the submit button too, but that didn't solve the problem. I've simplified the code by a lot here, and ran it testing it too.
In your html code, you have missed =
for name
name="username"
Instead of name"username"
Here's your fixed code.
<input type="text" name="username" value="" placeholder="User Name"> <br />
<input type="password" name="password" value="" placeholder="Password"> <br />
<input type="password" name="passwordConfirm" value="" placeholder="Confirm Password"> <br />
<!-- ?type email or type text -->
<input type="email" name="email" value="" placeholder="Email" autofocus> <br />
the ploblem is not at register.php
you can try to write like this:
if ( isset($_POST['username']) ) {
$postUsername = $_POST['username'];
echo $postUsername;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With