我是PHP的新手,我有一个关于我的Javascript目前无法正常工作的问题。
到目前为止,这是我的代码
<?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>
从上面的代码中,我在此页面中的结果只是一个纯白页。
当我试图测试未完成的表格案例和密码不匹配时。但是没有弹出警报。即使插入了表单页面中的所有字段,此页面仍为纯白色。
请帮忙。
答案 0 :(得分:3)
代码中的各种问题:
isset()
。启用错误报告,您会发现许多Notice: Undefined index
错误return
为什么if
?这是一个功能吗?在您的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";';
}
您的所有HTML字段均为hidden
,用户在哪里输入值?
答案 1 :(得分:0)
使用;内部回声声明
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";';
}