-1

如何将 PHP 变量值从一个 PHP 块获取到同一 PHP 页面中的另一个 PHP 块

<?php
//If the form is submitted
$name=$school=$web=$location=$phone=$email=$comments="";
if(isset($_POST['submit'])) {

    //Check to make sure that the name field is not empty
    if(trim($_POST['Full']) == '') {
        $hasError = true;
    } 
    else if (!preg_match("/^[a-zA-Z ]*$/",trim($_POST['Full']))){
        $hasError = true;
        $nameErr = "Only letters and white space allowed";
    }
    else {
        $name = secure_data($_POST['Full']);
    }
:
:

jquery 和 HTML 代码之间有,那么

<tr>
    <td valign="top"><label for="Full" class="label">Full Name<span class="required_star"> * </span></label></td>
    <td width="310" valign="top"><input type="text" name="Full" id="Full" value=""  maxlength="80" style="width:230px"/></td>
    <td width="159" class="status"><font color="#CC0000"><?php echo $nameErr;?></font></td>
</tr>

出现错误 -

注意:未定义变量:C:\xampp\htdocs\manazeschool\contact_us.php 中的 nameErr 第 232 行

4

1 回答 1

0
<?php echo isset($nameErr) ? $nameErr : 'No Error';?>
于 2013-11-14T20:41:20.230 回答