What is the best way to send your messages like error messages from one php page to other php page. I do not want to use implode function, also i do not want messages to be displayed in address bar. Using this code $pageurl.= '?errors[]=' . implode('&errors[]=', array_map('urlencode', $errors)); My error messages generated by entering incorrect information by user got displayed in address bar, which is something i do not want. Kindly help.
Asked
Active
Viewed 96 times
-1
-
Use POST instead of get? Lets see some code – RyanS Feb 06 '14 at 19:07
-
Looks like you need to follow a tutorial about web development with PHP, maybe even one on HTTP alone. As above, use POST instead of GET. – givanse Feb 06 '14 at 19:26
-
Did you check this answer? I think this is a duplicate question. http://stackoverflow.com/a/2205609 – Binoj D Feb 12 '14 at 12:17
1 Answers
0
Use session data. It is stored on the server and kept between page loads.
Page that determines errors:
<?php
session_start():
// something happens here to cause errors
$_SESSION['my_error'] = array(
'Field 1 is incorrect',
'Field 3 is incorrect'
);
// whatever happens here to send user to next page
Page that displays errors:
<?php
session_start();
// check for set errors
if (isset($_SESSION['my_error']) && !empty($_SESSION['my_error']))
{
foreach ($_SESSION['my_error'] as $error)
{
echo $error.'<br>';
}
// unset them if not needed anymore
unset($_SESSION['my_error'];
}

Samutz
- 2,310
- 4
- 24
- 29