在PHP中获取未定义的变量错误

时间:2013-11-14 20:35:22

标签: php

如何从同一个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>

获取错误 -

  

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

1 个答案:

答案 0 :(得分:0)

<?php echo isset($nameErr) ? $nameErr : 'No Error';?>