News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Send data to website

Started by Farabi, August 11, 2008, 07:02:56 PM

Previous topic - Next topic

Farabi

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.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

hoverlees

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]

Farabi

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
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

#3
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?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Mark Jones

Hello Farabi, perhaps this link can be of help.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Farabi

Quote from: Mark Jones on August 19, 2008, 02:46:39 PM
Hello Farabi, perhaps this link can be of help.
No, it talk about winsock and Im using WinInet.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

evlncrn8

well wininet is just a big wrap of winsock nehows, just with proxy support etc 'built' in and other 'handlers'

ragdog

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

xmetal

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.

ragdog

Thanks

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

ragdog

drhowarddrfine

Your slashes are going the wrong way:
http://

ragdog

thanks for you post

this routine works without www. and http

ragdog

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