Page 1 of 1
error passing
Posted: Mon Jul 18, 2005 6:26 am
by Ree
on my current admin interface, when a user adds a new db record (via form), the POST of the form goes to a certain php file where entered data is processed. after that i forward the user to another page (let's say page.php)(i use header) on which i want to be able to display a message (something like 'Data entered successfully' or error message). i know i could just pass a message variable via query string, check it on page.php and display the appropriate message, but i don't want it possible to enter something similar to //domain/admin/page.php?error=added_ok in the browser and see the page.php with corresponding error message. what would be your suggestions to solve the problem?
Posted: Mon Jul 18, 2005 6:46 am
by timvw
use
http://www.php.net/session... (Other alternatives: cookies, database, files but notice that session can be used as a wrapper for those alternatives)
Posted: Mon Jul 18, 2005 7:51 pm
by harrisonad
I offer a simpler solution than what master timvw intelligently suggested.
Request Strings:
Code: Select all
admin/page.php?msgtype=success
admin/page.php?msgtype=error
admin/page.php
Page.php
Code: Select all
$msgtype = (isset($_GET['msgtype'])?$_GET['msgtype']:'success'); // provide default value
if($msgtype=='success'){
$msg = 'Transaction completed successfully!';
}elseif($msgtype=='error'){
$msg = 'An error occured while processing the transaction';
}
echo $msg;
Posted: Tue Jul 19, 2005 1:06 am
by Ree
thank you, harrisonad, but i already know your suggested way, and if you read my post more carefully, you would have noticed that.
