Re: HTTP_Clients and Files - Part 2

From: Date: Mon, 15 Nov 2004 22:34:27 +0000
Subject: Re: HTTP_Clients and Files - Part 2
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-15551@lists.php.net to get a copy of this message
On Mon, 15 Nov 2004 17:20:51 -0500, Andrew Nagy <asnagy@webitecture.org> wrote: > Justin Patrin wrote: > > > > >>How can I get a variable from the query string from one post() response > >>and then send it to my next post()? > >> > >>Anyone have any experience with this? > >> > > > > > > Yes, I have experience doing all sorts of crazy things with > > HTTP_Client. Usually sessions use cookies, which HTTP_Client handles > > for you. If it is indeed in a hidden field in the form, then you're > > going to have to parse out the value and set it yourself in your post > > request. I suggest using preg_match(). If you need regex help, post > > the relevant part of the form HTML and we can try to help. > > > > For some reason, this site isn't using cookies for it's sessions, it's > passing the id in the query string and through hidden fields. > > So are you saying that I need to parse through the resulting HTML to > pull out the id from a link or something? What if their is not link on > the page and it is just a form? > You need to parse out the value you need. As I said before, parse out the value of the hidden field. Look at the HTML source of the page and find the hidden field and write a regex to pull it out. I'm willing to help if you post the form's HTML. Something like this: preg_match('!<input[^>]*type=("|'|)hidden\1[^>]*name=("|'|)NAMEOFTHEFIELD\2[^>]*value=("|')([^\3]*)\3[^>]*>!i, $text, $matches); You value should be in $matches[4]. Note: this won't work if the value doesn't have quotes around it. If it doesn't, you can use a differen regex. -- Justin Patrin

« previous php.pear.general (#15551) next »