Forum   Search   Register   Log in SUPERJER FORUM
 

Post From PHP Page to PHP Page

Pages: [1]
Programming Help
sprinkles

Chrome Whore
2009 Sep 6 • 2480
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.
...then I got some ap, and shot a big ass lazar at everyone.
    (Edited 2012 Feb 1 at 14:50)     2012 Feb 1 at 14:45
Rockbomb
Dog fucker

2009 Nov 13 • 1943
-190 ₧
Try it and see.
    2012 Feb 1 at 14:47
superjer
superjer

2005 Mar 20 • 3767
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
sprinkles

Chrome Whore
2009 Sep 6 • 2480
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?
...then I got some ap, and shot a big ass lazar at everyone.
    2012 Feb 3 at 19:53
superjer
superjer

2005 Mar 20 • 3767
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.
    (Edited 2012 Feb 17 at 19:20)     2012 Feb 17 at 19:19

Pages: [1]
Forum and design copyright © 2008-2010 SuperJer.com