Autmating posting data to a php-based website

Thread Solved

Join Date: Dec 2008
Posts: 57
Reputation: khr2003 is an unknown quantity at this point 
Solved Threads: 0
khr2003 khr2003 is offline Offline
Junior Poster in Training

Autmating posting data to a php-based website

 
0
  #1
Jan 13th, 2009
I am not sure where to post this topic but I though this section is the right one.

I have a large amount of data in a MS word file. Basically, I want to automate the posting of this data into my website through the normal form of posting topics into my website.

Is there any way to do that?
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 93
Reputation: humbug is an unknown quantity at this point 
Solved Threads: 13
humbug's Avatar
humbug humbug is offline Offline
Junior Poster in Training

Re: Autmating posting data to a php-based website

 
0
  #2
Jan 14th, 2009
Using any program that can use sockets you can do this. If you have php installed on your computer then that's easy. I have done it with Game Maker (using 39dll) before.

What you need to do is read the file (word doc) into your program. (You may need to convert it to HTML or something...) Lets assume your using PHP. Use the fopen() function to read the file into a variable, say $file_content .

Then you want to make a socket connection to your website server:
$pointer = fsockopen("www.yourdomain.com",80); And then write a HTTP request containing the data. This is what your internet browser does when you submit a form. It should look something like this:
  1. POST /submit.php HTTP/1.1
  2. Host: www.yourdomain.com
  3. Connection-length: 24
  4. Connection: close
  5.  
  6. content=Content of file.
Each line must end in "\r\n" (PHP notation) and an empty line represents the end of the header and the start of the content.

The above would be the result of submitting the following form:
  1. <form action="www.yourdomain.com/submit.php" method="POST">
  2. <input type="text" name="content" value="Content of file." />
  3. <!-- submit etc. -->
  4. </form>

You then use fputs() to "write" the request to your server and fgets() to "read" the response from your server (which in this case isn't as crucial).

So, load file, connect to server, construct a correct HTTP request, send it, retrieve the reply to your request to make sure it all went ok.
"If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 57
Reputation: khr2003 is an unknown quantity at this point 
Solved Threads: 0
khr2003 khr2003 is offline Offline
Junior Poster in Training

Re: Autmating posting data to a php-based website

 
0
  #3
Jan 19th, 2009
thank you very much
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC