denoteone Posted August 7, 2008 Share Posted August 7, 2008 I am creating a form that will be used on every page. onSubmit i want to pass to the php function the url of the page the sent the info. I don't want to have to go and add a hidden field to every form on every page if I don't have to. Is there anyway around this? Quote Link to comment https://forums.phpfreaks.com/topic/118648-get-the-current-page/ Share on other sites More sharing options...
DarkWater Posted August 7, 2008 Share Posted August 7, 2008 Well, this is Javascript basically. It would be window.location.href. Quote Link to comment https://forums.phpfreaks.com/topic/118648-get-the-current-page/#findComment-610818 Share on other sites More sharing options...
denoteone Posted August 7, 2008 Author Share Posted August 7, 2008 ok so have a javascript function that runs onSubmit and assigns a value to a hidden field. that sounds good. Quote Link to comment https://forums.phpfreaks.com/topic/118648-get-the-current-page/#findComment-610825 Share on other sites More sharing options...
DarkWater Posted August 7, 2008 Share Posted August 7, 2008 Just so you know, it can still be tampered with by the submitter because well, it's Javascript and all form data is easily tampered with. Quote Link to comment https://forums.phpfreaks.com/topic/118648-get-the-current-page/#findComment-610829 Share on other sites More sharing options...
moselkady Posted August 7, 2008 Share Posted August 7, 2008 Maybe you can add this hidden field: <input type='hidden' name='src_file' value='<?php echo $PHP_SELF?>'> Quote Link to comment https://forums.phpfreaks.com/topic/118648-get-the-current-page/#findComment-610833 Share on other sites More sharing options...
denoteone Posted August 7, 2008 Author Share Posted August 7, 2008 I would like to use moselkady idea. Does anybody know if that is possible? Quote Link to comment https://forums.phpfreaks.com/topic/118648-get-the-current-page/#findComment-610841 Share on other sites More sharing options...
moselkady Posted August 7, 2008 Share Posted August 7, 2008 Well, this is only possible if your HTML is generated by PHP. If you form is in regular HTML files, then I think you have to go with DarkWater's solution. Quote Link to comment https://forums.phpfreaks.com/topic/118648-get-the-current-page/#findComment-610857 Share on other sites More sharing options...
DarkWater Posted August 7, 2008 Share Posted August 7, 2008 Or just rename the file with a .php extension. =P Quote Link to comment https://forums.phpfreaks.com/topic/118648-get-the-current-page/#findComment-610859 Share on other sites More sharing options...
sasa Posted August 7, 2008 Share Posted August 7, 2008 look $_SERVER variable http://www.php.net/manual/en/reserved.variables.server.php Quote Link to comment https://forums.phpfreaks.com/topic/118648-get-the-current-page/#findComment-610868 Share on other sites More sharing options...
denoteone Posted August 7, 2008 Author Share Posted August 7, 2008 my file name is called page2.php because i am using php includes on the page. so that should work then. Quote Link to comment https://forums.phpfreaks.com/topic/118648-get-the-current-page/#findComment-610929 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.