Jump to content

SERVER['REQUEST_URI']


knichel

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/131824-serverrequest_uri/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/131824-serverrequest_uri/#findComment-684770
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/131824-serverrequest_uri/#findComment-684812
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.