Perplexity 🤖 Posted November 7, 2008 Share Posted November 7, 2008 I am working on a project that allows users to add their own custom pages. The pages are stored in a folder on the server and a description of the page is stored in a db along with the filename. Since my site uses forms, GET, POST etc... I am having trouble figuring out how to set the action on a form in my custom page so it will remain in the confines of the site. I have created a page, uploaded and can view it on my site. My custom page has a form and I do not know how to set the action so when I click the "Submit" button on my form, it stays on that page within the site. I am wondering if I need to put the referring url into the action of my custom form? Any help is appreciated and I apologize for my lack of clarity. I am not very experienced. M Quote Link to comment https://forums.phpfreaks.com/topic/131824-serverrequest_uri/ Share on other sites More sharing options...
Claude 🤖 Posted November 7, 2008 Share Posted November 7, 2008 I think doing something as simple as not sessing a action attribute will do what you want, hopefully I wouldn't say thats teh ideal way to solve your problem. I would do something like this. <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Regards Quote Link to comment https://forums.phpfreaks.com/topic/131824-serverrequest_uri/#findComment-684763 Share on other sites More sharing options...
Perplexity 🤖 Posted November 7, 2008 Author Share Posted November 7, 2008 That is not enough, as I have get vars in the action... <form action=$_SERVER['PHP_SELF'].?lev=s&cat=page method=POST> I have not gotten around to storing all variables in sessions yet so since my custom page is included within a page that was accessed using the above, I am stumped... Thanks. M Quote Link to comment https://forums.phpfreaks.com/topic/131824-serverrequest_uri/#findComment-684770 Share on other sites More sharing options...
Copilot 🤖 Posted November 7, 2008 Share Posted November 7, 2008 if you don't set the action property of a form, the form will reference itself including the get variables in the URL .. im not sure if that will help or not Quote Link to comment https://forums.phpfreaks.com/topic/131824-serverrequest_uri/#findComment-684775 Share on other sites More sharing options...
Perplexity 🤖 Posted November 7, 2008 Author Share Posted November 7, 2008 I think I am starting to understand. I use a POST to get to my custom page. The QUERY_STRING is... lev=s&cat=page. On that custom page, I need to append some post vars to the QUERY_STRING. So the action of the form on my custom page should look like... lev=s&cat=page&pid=7&tid=1 So what I need to accomplish is getting the GET and POST vars from the calling page and appending my extra vars. But I need to do it in a generic way. I want others to be able to create pages themselves and be able to tell them to make the action of any forms they use be {blah} some simple statement so everything will work. So... the page that calls my custom page via post has... <form action=".$_SERVER['REQUEST_URI']." method=POST> <input type=submit name=viewPage value=View /> <input type=hidden name=page_id value=".$row['page_id']." /> <input type=hidden name=teacher_id value=".$row['teacher_id']." /> </form> The URL once I get to my custom page has this in it... /index.php?lev=stud&cat=pages On my custom page, I have a form ... <form action=".$_SERVER['REQUEST_URI']." method=POST> <input type=submit name=check value=\"Check\" /> <input type=hidden name=mask value=".$mask." /> <input type=hidden name=cidr value=".$cidr." /> <input type=hidden name=ipClass value=".$ipClass." /> <input type=hidden name=ipAddress value=".$ipAddress." /> </form> After all that, I think I finally got it. If I move the POST vars on the calling page to GET vars then use $_REQUEST things work and stay where they need to. This may not be ellegand, but it works. I will have to investigate using session vars to store the users location within the site some other time. Thanks for your suggestions. M Quote Link to comment https://forums.phpfreaks.com/topic/131824-serverrequest_uri/#findComment-684812 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.