我无法找到下面描述的此问题的解决方案。它显示变量$ fName和其他变量(例如$ MNane)以及其他变量(例如$ fnameerr等)是未定义的,即使我稍后在php脚本中定义了它们也是如此。
我正在尝试通过验证的注册表。我从来没有遇到过这个问题,因为以前该代码已经完美地运行过很多次。我对这种语言不了解。
HTML代码:
div_i_am_targeting
PHP代码:
<!-- Header -->
<header class="masthead bg-primary text-white text-center">
<div class="container">
<img class="img-fluid mb-5 d-block mx-auto" src="img/profile.png"
alt="">
<h1 class="text-uppercase mb-0">SOCIETY-123</h1>
<hr class="star-light">
<h2 class="font-weight-light mb-0">Maintain your house on Rent - Sell
house - Manage the Society</h2>
</div>
</header>
<div>
<form method="post" action="<?php echo htmlspecialchars($_SERVER[PHP_SELF]); ?>">
<center><h1 class="text-uppercase mb-0">Registration</h1></center>
<hr class="star-dark mb-5">
<table class="registration1">
<tr>
<td style="padding-right: 60px;">Firstname:<input type="text" name="FName" placeholder=" Firstname" value="<?php echo $FName;?>"><span><?php echo $FNameerr;?></span></td>
<td style="padding-right: 60px;">Middlename:<input type="text" name="MName" placeholder=" Middlename" value="<?php echo $MName;?>"><span><?php echo $MNameerr;?></span></td>
<td style="padding-right: 60px;">Lastname:<input type="text" name="LName" placeholder=" Lastname" value="<?php echo $LName;?>"><span><?php echo $LNameerr;?></span></td>
</tr>
<tr style="padding-top: 30px;">
<td style="padding-top: 30px;">Gender: Male<input type="radio" name="Gender" <?php if(isset($Gender) && $Gender == "male") echo checked;?> value="male"></td>
<td style="padding-top: 30px;">Female<input type="radio" name="Gender"<?php if(isset($Gender) && $Gender == "female") echo checked;?> value="female"></td>
<td style="padding-top: 30px;">other<input type="radio" name="Gender"<?php if(isset($Gender) && $Gender == "other") echo checked;?> value="other"><span><?php echo $Gendererr;?></span></td>
</tr>
<tr>
<td style="padding-top: 30px;">Address: <input type="text" name="add" placeholder="Type your address here" size="30" value="<?php echo $add;?>"><span><?php echo $adderr;?></span></td>
<td style="padding-top: 30px;">Occupation<input type="text" name="occu" placeholder=" occupation" value="<?php echo $occu;?>"><span><?php echo $occuerr;?></span></td>
</tr>
<tr>
<td style="padding-top: 30px;">Residence type: self owned<input type="radio" name="Resi"<?php if(isset($Resi) && $Resi == "selfowned") echo checked;?> value="selfowned"></td>
<td style="padding-top: 30px;"> Rented<input type="radio" name="Resi"<?php if(isset($resi) && $Resi == "rented") echo checked;?> value="rented"><span><?php echo $Resierr;?></span></td>
</tr>
<tr>
<td style="padding-top: 30px;">E-mail id:<input type="text" name="eid" placeholder=" e-mail id" value="<?php echo $eid;?>"><span><?php echo $eiderr;?></span></td>
<td style="padding-top: 30px;">password:<input type="password" name="pass" placeholder=" password" value="<?php echo $pass;?>"><span><?php echo $passerr;?></span></td>
</tr>
<tr>
<td><input type="button" name="submit" value="submit" value="submit"></td>
</tr>
</table>
</form>
尽管我已经在php脚本中定义了变量
答案 0 :(得分:0)
您可以尝试一下,希望它能起作用
<tr>
<td style="padding-right: 60px;">Firstname:<input type="text"
name="FName" placeholder=" Firstname" value="<?= (!empty($FName)) ? $FName : "" ?>">