dongwen7187 2012-09-11 07:27
浏览 8

表单输入字段

I have a form that gets it values from a database and when submitted checks if the values are empty or not. The values are currently being filled in, but when checked are not registering as being there.

simplified form code:

if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) {
 echo '<ul class="err">';
foreach($_SESSION['ERRMSG_ARR'] as $msg) {
    echo '<li>',$msg,'</li>'; 
}
echo '</ul>';
unset($_SESSION['ERRMSG_ARR']);
}
<form action="addStudent.php" method="post" >
 <?php
     $result = mysql_query("SELECT firstname, lastname FROM members WHERE login='$_SESSION[SESS_LOGIN]'");
    $row = mysql_fetch_array($result);
 ?>
Student Name: <input type="text" name="student" value="<?php echo $row['firstname'] . ' ' . $row['lastname']; ?>" >
<input type="submit" value="Submit" >
</form>

Code that checks if values empty:

$errmsg_arr = array();
$errflag = false;
function clean($str) {
   $str = @trim($str);
   if(get_magic_quotes_gpc()) {
        $str = stripslashes($str);
    }
   return mysql_real_escape_string($str);
  } 
$student = clean($_POST['student']);

if($student == '') {
$errmsg_arr[] = 'Please add student name.';
$errflag = true;
} 

if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: classSignUp.php);
    exit();
}

What is really confusing me is that this was working on my localhost and now when I am trying to transfer the code it has stopped working. I don't believe it is an issue with my database because the values are being filled into the form, just not showing up as having a value when I submit it.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么