Evrim Posted June 22, 2009 Share Posted June 22, 2009 Hello I have a php page that checks the values of a html form. If some elements of the form are missing or have incorrect format, it will display messages to the user. 1. My checkform.php page contains a code like: $missing1 = "The following fields are missing: "; if ($key=='gender' && empty($val)) { $missing1 .= " Gender; " ; echo $missing1;} if ($key=='address' && empty($val)) { $missing1 .= "Home address; " ; echo $missing1; } // More checks of the same type $togourl ="../errors.php?missing1=$missing1"; header("Location: $togourl"); 2. In my errors.php I have: <tr> <td> <?php echo $_GET['missing1']; ?> </td> </tr> 1. The problem is that I only see one word in my errors.php, which is "The". When I remove the statement header("Location: $togourl") from my code, I see the missing1 var is correct (by checking echo in the code), but when displaying in second page I have a problem. Could you help me? Everything else (html) shows fine in the table of the second page. 2. What method you suggest so I store the missing fields in array and pass it on to errors.php and show it in several lines threre? Many many thanks Evrim Quote Link to comment https://forums.phpfreaks.com/topic/163258-echo-_getmissing-shows-one-word-only/ Share on other sites More sharing options...
Adam Posted June 22, 2009 Share Posted June 22, 2009 Try removing the echo statements, otherwise you're trying to redirect to another page after you've printed content to the page. Quote Link to comment https://forums.phpfreaks.com/topic/163258-echo-_getmissing-shows-one-word-only/#findComment-861324 Share on other sites More sharing options...
Evrim Posted June 22, 2009 Author Share Posted June 22, 2009 Thanks for taking the time to reply. I commented the echo statemetns and still have the same problem. Please help! Quote Link to comment https://forums.phpfreaks.com/topic/163258-echo-_getmissing-shows-one-word-only/#findComment-861333 Share on other sites More sharing options...
Evrim Posted June 25, 2009 Author Share Posted June 25, 2009 Hello everybody I wonder if someone has any suggestions for me? Thanks ??? :'( Quote Link to comment https://forums.phpfreaks.com/topic/163258-echo-_getmissing-shows-one-word-only/#findComment-863340 Share on other sites More sharing options...
Dathremar Posted June 25, 2009 Share Posted June 25, 2009 I would suggest creating an array of the errors and pass them as a single variable through the URL something like: $error_array = array(); if ($key=='gender' && empty($val)) { $error_array[] = "Gender" ; } if ($key=='address' && empty($val)) { $error_array[] = "Home address" ; } $togourl ="../errors.php?missing1=".serialize($error_array); header("Location: $togourl"); And in the errors.php $error_array = unserialize($_GET["missing1"]); // Then do a loop to print out the items in the array Quote Link to comment https://forums.phpfreaks.com/topic/163258-echo-_getmissing-shows-one-word-only/#findComment-863349 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.