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.