error passing
Moderator: General Moderators
error passing
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?
use http://www.php.net/session... (Other alternatives: cookies, database, files but notice that session can be used as a wrapper for those alternatives)
- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
I offer a simpler solution than what master timvw intelligently suggested.
Request Strings:
Page.php
Request Strings:
Code: Select all
admin/page.php?msgtype=success
admin/page.php?msgtype=error
admin/page.phpCode: 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;