Reputation: 193
I'm new to PHP and I have a problem about my Javascript is not working for now.
Here is my codes so far
<?php
$email = $_POST["App_Email"];
$password = $_POST["App_Password"];
$name = $_POST["App_Name"];
$lName = $_POST["App_LName"];
$gender = $_POST["App_Gender"];
$birthday = $_POST["App_Birthday"];
$nationality = $_POST["App_Nationality"];
$telNumber = $_POST["App_Tel"];
$address = $_POST["App_Address"];
$district = $_POST["App_District"];
$city = $_POST["App_City"];
$zipcode = $_POST["App_Zipcode"];
$repass = $_POST["RePassword"];
$message = "";
if($email == "" or $password == "" or $repass == "" or $name == "" or $lName == "" or $birthday == "" or $nationality == "" or $telNumber == "" or $address == "" or $district == "" or $city == "" or $zipcode == "" ){
$message = "FILL ALL";
}
elseif($repass != $password){
$message = "NOT MATCH";
}
echo '<script type="text/javascript">';
if($message == "FILL ALL"){
echo 'alert("Please fill in all provided field(s).")';
echo 'location.href = "registration.php"';
return;
}
else if($message == "NOT MATCH"){
echo 'alert("Your confirmation password is not match with your password.")';
echo 'location.href = "registration.php"';
return;
}
echo '</script>';
?>
<br><br>
<form method="POST" action="confirm-registration.php">
Name : <?php echo $_POST["App_Name"]; ?><br><br>
Lastname : <?php echo $_POST["App_LName"]; ?><br><br>
Gender : <?php echo $_POST["App_Gender"]; ?><br><br>
Date of birth : <?php echo $_POST["App_Birthday"]; ?> <br><br>
Nationality : <?php echo $_POST["App_Nationality"]; ?><br><br>
Tel. : <?php echo $_POST["App_Tel"]; ?><br><br>
Address : <?php echo $_POST["App_Address"]; ?><br><br>
District : <?php echo $_POST["App_District"]; ?><br><br>
City : <?php echo $_POST["App_City"]; ?><br><br>
Zipcode : <?php echo $_POST["App_Zipcode"]; ?><br><br>
<input type='hidden' name='App_Email' value='<?=$email?>'>
<input type='hidden' name='App_Password' value='<?=$password?>'>
<input type='hidden' name='App_Name' value='<?=$name?>'>
<input type='hidden' name='App_LName' value='<?=$lName?>'>
<input type='hidden' name='App_Gender' value='<?=$gender?>'>
<input type='hidden' name='App_Birthday' value='<?=$birthday?>'>
<input type='hidden' name='App_Nationality' value='<?=$nationality?>'>
<input type='hidden' name='App_Tel' value='<?=$telNumber?>'>
<input type='hidden' name='App_Address' value='<?=$address?>'>
<input type='hidden' name='App_District' value='<?=$district?>'>
<input type='hidden' name='App_City' value='<?=$city?>'>
<input type='hidden' name='App_Zipcode' value='<?=$zipcode?>'>
<button onClick="history.back()";> Back </button> <input type="submit" name="submit" value="Confirm">
</form>
From the codes above, my result in this page is just a plain white page.
When I tried to test the not completed the form case and password is not matched. But no alert is pop-up. Even all fields from the form page is inserted, this page stills plain white.
Please help.
Upvotes: 1
Views: 782
Reputation: 902
Use ; inside echo statements
if($message == "FILL ALL"){
echo 'alert("Please fill in all provided field(s).");';
echo 'location.href = "registration.php";';
}
else if($message == "NOT MATCH"){
echo 'alert("Your confirmation password is not match with your password.");';
echo 'location.href = "registration.php";';
}
Upvotes: 0
Reputation: 13293
Various problems in your code:
isset()
. Turn on your error reporting, you will find numerous Notice: Undefined index
errorsreturn
in if
? Is it a function?Missing ;
in your Javascript:
if($message == "FILL ALL"){
echo 'alert("Please fill in all provided field(s).");';
echo 'location.href = "registration.php";';
}
else if($message == "NOT MATCH"){
echo 'alert("Your confirmation password is not match with your password.");';
echo 'location.href = "registration.php";';
}
All your HTML fields are hidden
, where does the user enter values?
Upvotes: 3