Jump to content

a simple question regarding $_post


antonyfal

Recommended Posts

Hi,

I just wanted to know how posting works?.

 

i know how to sort of post and get info..

What i want to know is: is it possible to post something from a folder structure like so:

 

http://wwww.xxx.com/postfolder1/postfolder2/postfolder3/postfolder4/form.php  // this is the file that posts.. lets say! a username.

 

to

 

http://www.xxx.com/notpostfolder1/notpostfolder2/notpostfolder3/notpostfolder4/index.php // the file that gets the post : The username..

 

or is a php database the only answer to transfer the information?

 

i also just discovered that in cookies if i ad path/ the cookie is valid through out the site.. is ther something like this for Post and get??

 

 

Link to comment
Share on other sites

You can post anything to anything. A POST is simply a request to a page. You can see in AJAX that POST works relatively the same as GET. Consider the following AJAX lines:

 

storeAjax.open("POST",url,true);
storeAjax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
storeAjax.send(parameters);

 

The variables are still var=blah&var2=blah2 Its just passed through (I think) the headers.

 

That being said, you can post anything to anything. This is one reason (of many) as to why cross site scripting hacks are possible. I could post to CNN.com if I wanted to. POST / Get works in the request. That means if you don't repost the data every time, the data is lost. That's why it only works for one page. If you are trying to make a login, the first page for the login would be the form, then the receiving page would read that post variable and have to store it in a session or cookie. Now-a-days people seem to prefer session over cookies, but both work relatively the same. The benefit of a session is that the actual data is stored on the server and a unique id is stored on the browser.

Link to comment
Share on other sites

Thanks for the reply..

 

Ok, so what you saying is: If i wanted to post the route's as i showed above (example).. After i post from the form.php, my form.php's  redirect would have to go to the next route where the index.php is? otherwise i would loose the post? is this correct?

 

if so then would you say the next best method is cookies? or is there another method?

 

what i want to do is spread the form's information across several different folder's with index.php .

but not necessary in one session.. (session would be out of this equation)    //  ( just continuing the example above with index.php..)

Link to comment
Share on other sites

I'm still not entirely clear what you mean with the redirect or what the goal of hitting all those pages is. I also don't think you understand what a session is.

 

http://us2.php.net/manual/en/intro.session.php <- Read this for more information on sessions.

 

I know that everyone here is going to hate me for saying this, but without reading the above link it is the easiest way to explain it.

 

A SESSION is a COOKIE.

 

If you post from a.php to b.php you would get the info with $_POST['blah'] but if you go from b.php to c.php, you would have to repost the data or store it in a session then redirect like this:

 

in b.php:

$_SESSION['blah'] = "bananas";
header("Location: c.php");

 

then access it like this in c.php:

echo $_SESSION['blah'];

Link to comment
Share on other sites

Sorry for the late reply... i did some further checking... and read your article...

I get it now!!

posts last as long as a session.. so if i posted someting i would have to get it in the same session, otherwise i would have to re-post it.. I also understood you re-post explanation to move it accross forms..

 

I was trying to pass user information across the site but didnt want to use cookies, as the user may be in a internet cafe, and this would be a security risk.. So now i understand that i can use posting.. but on every page that contains the information, i can just repost the info, that way when the user has gone through the entire site, the information will spread to the correct places..

 

Why this way, you may ask? is because the original form that is filled in, is only viewed once in the entire workings of the site, and a part of the information is not stored in a database.... so the user would idealy have to be redirected to all the pages seeking the information one after the other in a single session (or so i thought).. But now i figured it out.

 

Thanks again for the advise and help

Best regards

Antony Falencikowski

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.