- This topic is empty.
-
AuthorPosts
-
July 19, 2013 at 4:27 pm #46543mikewaxParticipant
I am a bit new to the PHP realm..
I am trying to make this PHP back button work outside of a website. I am creating a widget, that can submit a form through PHP. But if there is an error in the form, it redirects to an Error page, and I need a back button in the error page to get back to the form. Since this is not in a web browser, there is no back button. And since I am not technically using the internet, the javascript:history.go(-1); code doesn’t work either, becasue there is no stored history in a widget. Basically, I have a local HTML file, that links to a PHP file on a server, and I need to get back to the HTML file (original page or the form).
That is what i have now in my PHP code, and can’t figure out how to get it to work. And I don’t really understand the PHP code given above.
I saw a post the tried to explain this with this code:
$url = htmlspecialchars($_SERVER);
echo “back“;
?>But I don’t quite understand that, and tried copying and pasting into my code with no success.
Any help is greatly appreciated. Thank you!
July 19, 2013 at 5:00 pm #143657chrisburtonParticipantWhy go through all this trouble? Just link to the page the form is on.
July 19, 2013 at 6:21 pm #143627mikewaxParticipantI can’t because the form is a local file. The PHP file is on a server, while the HTML file is in the Widget file locally.
July 19, 2013 at 6:42 pm #143630chrisburtonParticipantMay I ask what exactly you’re trying to do? Not your problem but the overall goal.
July 19, 2013 at 6:52 pm #143631mikewaxParticipantI am embedding a widget into iBooks Author, and the widget is a submission form. So the Widget contains the HTML file with my CSS and JavaScript files, and the PHP is on a server. The form POSTs to the PHP server, and gives an error message if, for example, the e-mail is incorrect. But, my problem is the only way to get to the form (local HTML file) is to completely close out of the widget, out of the book, and reload the book, which obviously erases everything inputted to the widget as well.
I need a way to get back to the local file, or to post the error message without leaving the original form page.
Thank you for all your help.
July 19, 2013 at 7:03 pm #143615drewwyattParticipantI agree with **chrisburton** here – that there may be a cleaner way to accomplish this. However, to directly answer your question – you could use [$_SERVER Variables](http://php.net/manual/en/reserved.variables.server.php “$_SERVER Variables”). Something like this might work:
0): ?>
“>Go Back
July 19, 2013 at 7:52 pm #143621AlenParticipantWhy don’t you do some client-side validation before posting data. And use AJAX… quick search resulted in: http://stackoverflow.com/questions/13924309/ajax-form-submission-with-php
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.