0 Members and 1 Guest are viewing this topic.
<!doctype html><html> <head> <title>My Page</title> </head> <body> <form action="handler.php" method="post"> <p><input type="text" name="text" id="text" /></p> <p><input type="submit" value="Go" /></p> </form> <body></html>
<?php $text = $_POST["text"]; //gets the text from the text field?>
It all depends on whether the client's browser decides to give that information to your script. The variable $_SERVER['HTTP_REFERER'], if set, refers to the page that led the user there. Unfortunately, browsers aren't obligated to set it in any way, so you can never be sure.
Actually, a more fail-proof method to do that (without Javascript) would be to use an <input type="hidden" name="url" value="CURRENT_URL" /> or something similar.
Quote from: Deep Thought on September 11, 2011, 03:00:23 pmActually, a more fail-proof method to do that (without Javascript) would be to use an <input type="hidden" name="url" value="CURRENT_URL" /> or something similar.Yes, but I don't really like to trust Javascript this things, because the user could delete it to make my php script fail. I like to think about anything that can happen.
Quote from: ephan on September 11, 2011, 03:03:40 pmQuote from: Deep Thought on September 11, 2011, 03:00:23 pmActually, a more fail-proof method to do that (without Javascript) would be to use an <input type="hidden" name="url" value="CURRENT_URL" /> or something similar.Yes, but I don't really like to trust Javascript this things, because the user could delete it to make my php script fail. I like to think about anything that can happen.Exactly, that's why I suggested using a hidden input. No JavaScript needed.
Quote from: Deep Thought on September 11, 2011, 03:32:19 pmQuote from: ephan on September 11, 2011, 03:03:40 pmQuote from: Deep Thought on September 11, 2011, 03:00:23 pmActually, a more fail-proof method to do that (without Javascript) would be to use an <input type="hidden" name="url" value="CURRENT_URL" /> or something similar.Yes, but I don't really like to trust Javascript this things, because the user could delete it to make my php script fail. I like to think about anything that can happen.Exactly, that's why I suggested using a hidden input. No JavaScript needed.When I said "Javascript", I meant the HTML Code. The user can change it I think, right?
Yes, I managed to do it in another way, but er, thanks everyone!
Quote from: Deep Thought on September 11, 2011, 03:00:23 pmActually, a more fail-proof method to do that (without Javascript) would be to use an <input type="hidden" name="url" value="CURRENT_URL" /> or something similar.That's actually what I was talking about, have the javascript grab it. Although hard coding it in would work better.Quote from: ephan on September 11, 2011, 04:50:52 pmYes, I managed to do it in another way, but er, thanks everyone!Np, glad to be able to give you some options. How did you actually go about doing it might I ask?