Jump to content

[SOLVED] Automated Form Stripper


GKWelding

Recommended Posts

Ok, I have a form on another web page that is not private or

protected. Basically what I want to do is load the form values that

are loaded when you view the webpage into a PHP script on another

server and then take those form values and load them into PHP

variables. I understand that loading the values into variables is the

easy bit, I was just wondering if there are any PHP functions I am

missing that allow PHP to load external web pages and preen data from

them?

 

Thanks in advance for the help...

Link to comment
Share on other sites

Cheers,

 

This may look like the only solution to my question. I will have to use the file_get_contents().

 

I guess the best solution for this problem would be to copy the entire completed form into a string generated by file_get_contents() then 'clip' out the bits of information I require. Example code to use for clipping the string once loaded, for those who are interested, is given below. I don't know if this will work yet as I'm not on my machine so don't hold me to this...

 

function strstr_after($haystack, $needle_start, $needle_end) {
    $pos_start = $strpos($haystack, $needle_start);
    $pos_end = $strpos($haystack, $needle_end);
    $length = $pos_end - $pos_start;
    if (is_int($pos_start) && is_int($pos_end)) {
        return substr($haystack, $pos_start+1, $length-1));
    }
    return $pos;
}

// Example
$email = 'name@example.com';
$domain = strstr_after($email, '@', '.');
echo $domain; // prints example

Link to comment
Share on other sites

So for the example above:

 

$email = 'name@example.com';
preg_match (!e(.+)e!, $email, $domain);
print_r($domain); // prints e@example

 

$email = 'name@example.com';
preg_match (!e(.+?)e!, $email, $domain);
print_r($domain); // prints e@e

 

Therefore the code below would give me everything between, and including, the input tags. I would have to set up some logic though to strip out every instance of them occuring in the string if they occur more than once though or do regular expressions support this?

 

$formstring = $file_get_string;
preg_match (!<input(.+?)input>!, $formstring, $matches);

 

I could then do a replace function on the input tags to leave just the data.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.