The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Farabi on August 11, 2008, 07:02:56 PM

Title: Send data to website
Post by: Farabi on August 11, 2008, 07:02:56 PM
I got a website, and I make that website is writeable. Here is the source:


Quote
poll.html
<form action="writer.php" method="post">
Nama: <input type="text" size="10" maxlength="40" name="peserta">
<br></br>
1. Are you using masm?
<select name="item1">
<option>yes</option>
<option>no</option>
</select>
<br></br>
<input type="submit" /></br>
</form>

Quote
Writer.php

<?php
$ip = getenv ('REMOTE_ADDR');
$date=date("j F, Y, g:i a");
$referer=getenv ('HTTP_REFERER');
$name = $_POST['peserta'];

$p1 = $_POST['item1'];
$p2 = $_POST['item2'];
$p3 = $_POST['item3'];
$p4 = $_POST['item4'];
$p5 = $_POST['item5'];
$p6 = $_POST['item6'];
$p7 = $_POST['item7'];
$p8 = $_POST['item8'];
$p9 = $_POST['item9'];
$p10 = $_POST['item10'];
$p11 = $_POST['item11'];
$p12 = $_POST['item12'];


$fp = fopen('Polling.txt', 'a');
fwrite($fp,'Nama: ' .$name. ' 1.1:' .$p1. ' 1.2:' .$p2. ' 2.1:' .$p3. ' 2.2:' .$p4. ' 2.3:' .$p5. ' 2.4:' .$p6. ' 2.5:' .$p7. ' 3.1:' .$p8. ' 3.2:' .$p9. ' 3.3:' .$p10. ' 3.4:' .$p11. ' 3.5:' .$p12. ' Date and Time:' .$date. ' IP: ' .$ip.  ' Referer: '.$referer. "\n");
fclose($fp);

?>


As you can see, the writer.php taking data from the website form (which is named as 'item1') and then write it to file. I want to know how to send form named item1 through item12 with its data on masm.
Sorry for my lack of english.
Title: Re: Send data to website
Post by: hoverlees on August 12, 2008, 02:06:11 AM
To use HTTP GET method ,you can do like this:
1.InternetOpen
2.InternetOpenUrl (send header here)

invoke InternetOpenUrl,hInternet,CTXT("http://localhost/a.php"),CTXT("item1=yes&item2=no"),19,NULL,NULL

3.InternetReadFile
4.InternetCloseHandle

To use HTTP POST method (also GET,PUT)
1.InternetOpen
2.InternetConnect
3.HttpOpenRequest
4.HttpAddRequestHeaders(also can add header in step 5)
5.HttpSendRequest
6.InternetReadFile
7.InternetCloseHandle

and here,an example for you.

[attachment deleted by admin]
Title: Re: Send data to website
Post by: Farabi on August 12, 2008, 04:22:52 AM
Quote from: hoverlees on August 12, 2008, 02:06:11 AM
To use HTTP GET method ,you can do like this:
1.InternetOpen
2.InternetOpenUrl (send header here)

invoke InternetOpenUrl,hInternet,CTXT("http://localhost/a.php"),CTXT("item1=yes&item2=no"),19,NULL,NULL

3.InternetReadFile
4.InternetCloseHandle

To use HTTP POST method (also GET,PUT)
1.InternetOpen
2.InternetConnect
3.HttpOpenRequest
4.HttpAddRequestHeaders(also can add header in step 5)
5.HttpSendRequest
6.InternetReadFile
7.InternetCloseHandle

and here,an example for you.
Thanks a lot.  :U
Title: Re: Send data to website
Post by: Farabi on August 19, 2008, 02:50:46 AM
Hi all,
Now I want to upload a file to the website and got no clue. I tried googling all the day but found nothing, anyone can help?

Here is the php script handling the file

<?php
$ip 
getenv ('REMOTE_ADDR');
$date=date("j F, Y, g:i a");
$referer=getenv ('HTTP_REFERER');
$name $_POST['filename'];

$file_to_read $_FILES['myfilevar']['tmp_name'];
$file_data implode("",file($file_to_read));

$fp fopen($name'w');
fwrite($fp,$file_data); 
fclose($fp);

?>



What should I send using HttpSendRequest?
Title: Re: Send data to website
Post by: Mark Jones on August 19, 2008, 02:46:39 PM
Hello Farabi, perhaps this link (http://www.madwizard.org/programming/tutorials/netasm/) can be of help.
Title: Re: Send data to website
Post by: Farabi on August 20, 2008, 02:01:00 AM
Quote from: Mark Jones on August 19, 2008, 02:46:39 PM
Hello Farabi, perhaps this link (http://www.madwizard.org/programming/tutorials/netasm/) can be of help.
No, it talk about winsock and Im using WinInet.
Title: Re: Send data to website
Post by: evlncrn8 on August 20, 2008, 12:27:53 PM
well wininet is just a big wrap of winsock nehows, just with proxy support etc 'built' in and other 'handlers'
Title: Re: Send data to website
Post by: ragdog on September 01, 2008, 09:46:35 AM
Hi

I have played with this source i become this messages

if i send post data to a login page.

invoke SendRequest,CTXT("http:\\xxx.com"),CTXT("/login.php"),CTXT("username=test1&password=test2"),addr retBuf,1000

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>

have your an idea why this not work

greets,
ragdog
Title: Re: Send data to website
Post by: xmetal on September 01, 2008, 03:10:11 PM
Quote from: ragdog on September 01, 2008, 09:46:35 AM
invoke SendRequest,CTXT("http:\\xxx.com"),CTXT("/login.php"),CTXT("username=test1&password=test2"),addr retBuf,1000

"http://xxx.com"

HTH.
Title: Re: Send data to website
Post by: ragdog on September 01, 2008, 03:36:13 PM
Thanks

i have this solved without http:\\ or www. only xxx.com

ragdog
Title: Re: Send data to website
Post by: drhowarddrfine on September 01, 2008, 07:12:27 PM
Your slashes are going the wrong way:
http://
Title: Re: Send data to website
Post by: ragdog on September 02, 2008, 03:18:28 PM
thanks for you post

this routine works without www. and http
Title: Re: Send data to website
Post by: ragdog on September 07, 2008, 02:29:13 PM
hi

I have a another problem with this source why works this not?

invoke SendRequest,CTEXT ("http://www.masm32.com"),CTEXT ("/board/index.php?"),CTEXT ("action=search2&search=masm32"),addr retBuf,1000

has any an idea?

greets