The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 23, 2019, 02:44:22 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Perk's WebRequest Class - any FAQ?  (Read 3630 times)
earp_
n00b
*
Offline Offline

Posts: 5


View Profile
« on: October 23, 2008, 03:26:41 AM »

Hi guys, I want to pass $myVar to a form, with using class WebRequest2,  but i don't know how.
Is there anybody who can tell me how?

tks in advance.
Logged

No links in signatures please
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #1 on: October 23, 2008, 05:35:30 AM »

Need more information.

"pass to a form" is an odd way of putting it. Usually, forms give their input to particular scripts. Often these days, it's the script that generated the page you're currently on.

So where exactly is this form? Are you talking about using the webRequest class to POST data up to a remote webserver, or what?
Logged

hai
earp_
n00b
*
Offline Offline

Posts: 5


View Profile
« Reply #2 on: October 23, 2008, 06:01:24 AM »

Fair enough...
In myServer there is perk's class.
In secServer, in Page1 there is a form with a submit. If I click on that submit I go to Page2 where I can see the results from the previous page with the form (selects, input data...)

I was wondering if it's possible to put a similar form in a page (myPage) into myServer.
(and until here np)

Once I click on submit in myPage I recall webRequest2 passing the value from my form so as to obtain the same result that I would have gotten if I was clicking on submit in Page2 of secServer.

The problem is that I don't know how to pass a value of a select to webRequest2.

Pls tell me if it's too messy!  Need Help
Logged

No links in signatures please
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #3 on: October 23, 2008, 06:04:39 AM »

What you should do is install something like LiveHTTPHeaders for Firefox.

Actually, my personal favorite is Burp Proxy by Portswigger. With either of these tools you can see exactly how the POST packet you would like to send looks.

There's nothing magical happening when you post a form up to a webserver, it's just a string of text being sent.
Logged

hai
earp_
n00b
*
Offline Offline

Posts: 5


View Profile
« Reply #4 on: October 23, 2008, 06:39:47 AM »

what about if I use the function addGetParam or addPostParam?

What I was thinking is to click on submit of my form and redirect all the values to the page in secSever.

I don't want to use an addOns for firefox if it's possible.

tks for your previous answer.
« Last Edit: October 23, 2008, 06:47:04 AM by earp_ » Logged

No links in signatures please
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #5 on: October 23, 2008, 09:34:48 AM »

Hey earp, welcome to the Cache.

If you've looked at the HTML source and have identified the POST values that you want to move up to a server, then you are correct - you use the addPostParam to a webrequest to move them.

For example - if you saw
<input type="text" name="address" value="">
then you'd do an addPostParam like this:
$req->addPostParam('address', 'PO Box 12345');
- assuming the instance of webRequest was called $req.

Assuming then that you've put all the values you want to pass into variables on the PHP side, it's a simple change to go:
$myVar = 'PO Box 12345';
$req->addPostParam('address', $myVar);


Hope that does ya!


Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
earp_
n00b
*
Offline Offline

Posts: 5


View Profile
« Reply #6 on: October 25, 2008, 07:05:07 AM »

Yep that's what I was looking for...thanks a million.
 
Logged

No links in signatures please
earp_
n00b
*
Offline Offline

Posts: 5


View Profile
« Reply #7 on: October 25, 2008, 07:59:50 AM »

Another question...
let's say I have this

Quote
require ("classes/class.webrequest2.php");

$req = new webrequest2();
$req->debugMode = WRD_ECHO;
$buffer = $req->simpleGet('http://mysite.aspx?');
echo "\n\n\n\n$buffer\n";

if I want to pass mysite some arguments, I can put values inside a variable and do something like this.
myVar = "name=welcome&";
myVar = myvar."lastname=thanks";

and write

$buffer = $req->simpleGet('http://mysite.aspx?$myVar');

but if I want to do in your way

Quote
$myVar = 'PO Box 12345';
$req->addGETParam('address', $myVar);

I don't know how to add $myVar at the end.
maybe something like
Quote
require ("classes/class.webrequest2.php");

$req = new webrequest2();
$req->debugMode = WRD_ECHO;
$buffer = $req->simpleGet('http://mysite.aspx?');

$myVar = 'PO Box 12345';
$req->addGetParam('address', $myVar);

echo "\n\n\n\n$buffer\n";
but something is not clear. Will $buffer contain the values added with addGetParam ?
« Last Edit: October 25, 2008, 08:11:41 AM by earp_ » Logged

No links in signatures please
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #8 on: October 25, 2008, 11:31:01 AM »

In this case, a simpleGet is literally that: whatever you put in the string of the parameter is what you will send to the server.

So to extend your example:
$theName = 'perkiset';
$theAddress = 'PO Box 12345';
$buffer = $req->simpleGet("http://www.aserver.com/aPage.html?name=$theName&address=$theAddress");


It doesn't look like you are really strong with string dereferencing yet... as you see from the example above, if you use double quotes to surround your string, the PHP will dereference variables right into it, as opposed to single quotes which are static strings.

In your last example, you're adding a getParam AFTER you've done the simpleGet, which is not going to work at all, because you've already thrown the request at the server. All parameters must be set BEFORE you either ->simpleGet() or ->dispatch()
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!