Results 1 to 6 of 6

Thread: Submit a form (POST) via PHP.

  1. #1
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055

    Submit a form (POST) via PHP.

    Here is my problem.

    I have this supplier who offers drop shipping, I decided to try to add his entire product catalogue onto my site, both sites use oscommerce too... except...

    His company is obviously not very technical savvy, they wouldn't just give me a database dump and say they're working on setting up a web feed for their products. Whatever, if I don't get the products added in the next 30 days I'll miss christmas with them.

    So I hired someone to make a php web crawler that'd crawl their site, parse it all, and add the products to my database. It works great.... except... their website requires you login first to see prices. So my database has no prices in it.

    I could go in by hand and add them all, but i don't want to, I want an automated solution, and no, they don't have so much as a CSV pricelist.

    I tried faking the form by turning it into a GET request (query string) but oscommerce accesses the variables like this:

    if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
    $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
    So obviously it needs to be a post request.

    So, does anyone know of any way to use php to simulate a post request?
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  2. #2
    Registered
    Join Date
    Mar 2006
    Posts
    156
    I didn't quite get what you are trying to do, but you can certainly send a POST request through PHP using CURL: http://www.php.net/manual/en/ref.curl.php

    Examples of form submissions with cURL:
    http://www.higherpass.com/php/tutori...ote-Servers/2/
    http://www.shimul.info/archives/php/...-different-way

  3. #3
    Registered
    Join Date
    Aug 2006
    Location
    Sacramento, CA
    Posts
    208
    The Snoopy php class would make this very easy. It is easy to do POST requests and will keep track of cookies and session info to keep you logged in when you crawl the other pages. I've used it before for scripts to login to affiliate networks etc and automatically pull stats for me.

    Depending on how complex the crawler is it should be pretty easy to do and only take a couple mins. Let me know if you have any questions or need help.
    ________
    Honda cb750
    Last edited by rpanella; 03-17-2011 at 11:01 AM.

  4. #4
    Registered Alien
    Join Date
    Aug 2004
    Location
    .au/.sg
    Posts
    58
    Use cURL. It's easier and quicker!

  5. #5
    4x4
    Join Date
    Oct 2004
    Posts
    1,043
    Quote Originally Posted by rpanella View Post
    The Snoopy php class would make this very easy. It is easy to do POST requests and will keep track of cookies and session info to keep you logged in when you crawl the other pages. I've used it before for scripts to login to affiliate networks etc and automatically pull stats for me.

    Depending on how complex the crawler is it should be pretty easy to do and only take a couple mins. Let me know if you have any questions or need help.
    I was going to suggest snoopy class too. Works great.

    I was also going to suggest you have your php coder write-up a lil script 50 EASY LINES or less to just grab all the info from their db and e-mail you the txt/csv file (Or output XML to screen in your format)

    This way you can just say here's this file upload it to your WWW directory, and you run it This way you could easily check/get new products.

    I wrote something identical for OSC to create a "1 page" printable catalog for someone.



    -Todd

  6. #6
    Registered
    Join Date
    Mar 2006
    Posts
    156
    I never used the Snoopy class before, but after checking their code, i can see that they are using cURL too Only that they are not using curl php built in function probably because that class is from 2000 and probably those functions were kind of new to PHP back then.

    I would personally choose to use the curl built in functions of PHP.
    Last edited by Nico; 09-03-2007 at 05:38 AM. Reason: I just realized that i passed my 100 posts :)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •