Post From PHP Page to PHP Page

Post From PHP Page to PHP Page

sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
I wanted to know if I could post from within php to another php file.
Example
PHP code
try
{
// code
}
catch (Exception $e)
{
// post $e to error.class.php
}

Maybe not post per se, but at least send data ($e) to another php page (error.class.php)

And not through sessions. I know it can easily be done using sessions, but for some reason I don't like that idea.
 
 
 
2012 Feb 1 at 14:45 PST — Ed. 2012 Feb 1 at 14:50 PST
Rockbomb
Dog fucker (but in a good way now)

2009 Nov 13 • 2045
Try it and see.
 
 
 
2012 Feb 1 at 14:47 PST
SuperJer
Websiteman

2005 Mar 20 • 6629
You can use PHP to make an HTTP POST here but it wouldn't make much sense.

Generally the browser is what makes a POST.

In the exception handler, you could output a form with some javascript to cause the browser to immediately POST to your other page.

But that would be weird, too.

What are you actually trying to accomplish?
 
 
 
2012 Feb 3 at 19:35 PST
sprinkles

Chrome Whore
2009 Sep 6 • 2547
10 ₧
superjer said:
What are you actually trying to accomplish?

I want it so when I it.

No but for reals, I have error.php which handles all my errors and displays a user friendly 'error' page (and if its an admin tells them the error). It also does fancy things like log the error and notify me.

So naturally, when we encounter an error I want to send the error to error.php.

For example:
I spill some soap (the gel kind, because you can't really spill a bar [unless you melt it]) on my database. index.php phreaks out cause it can't connect to the database. So it sends the data/error to error.php. Then error.php nicely says "THE FUCKING DATABASE IS BROKEN D: ," logs the error, and notifies me.

That's pretty much what I want to happen.

I did accomplish this using sessions (and after displaying the error page we set the session['error'] back to null). But is there anyother way?
 
 
 
2012 Feb 3 at 19:53 PST
SuperJer
Websiteman

2005 Mar 20 • 6629
You could just
php code

<?php
include "error.php";
?>

and then in error.php end with an exit:
php code

<?php
echo "OH NOES";
// ...
exit;
?>

so it kills the script.
 
 
 
2012 Feb 17 at 19:19 PST — Ed. 2012 Feb 17 at 19:20 PST
Page [1]