Jump to content

Getting "Input" Values


doni49

Recommended Posts

I'm working on a screen scraping app (to perform tasks on my own WHM panel) and I'm having a bit of difficulty.

 

I need to retrieve the "Value" of ever input put field.

 

Here's a trimmed down copy of what I need to pull the data from.

 

$response = '                <tr><br>
                    <td class="densetbl-key">Max FTP Accounts</td><br>
                    <td class="densetbl-value"><input value="10" type="text" name="maxftp"></input></td><br>
                </tr><br>
                <tr><br>

                    <td class="densetbl-key">Max Email Accounts</td><br>
                    <td class="densetbl-value"><input type="text" value="250" name="maxpop"></input></td><br>
                </tr><br>';

 

In this example, I need to retrieve 250 from the second input field.

 

Heres what I've tried (and many variations of this) but $match keeps coming back as empty.  :(

 

preg_match('/(\w|\s*)<input value="(\w+)" type="text" name="maxpop">(\w|\s*)/mU',$response,$match);

 

Thanks a bunch!

Link to comment
https://forums.phpfreaks.com/topic/45188-getting-input-values/
Share on other sites

Thanks for the reply.  That helped.  But it didn't work for all the fields.  So I investigated further.  I noticed that the fields change the order for value, name and type for example:

<input value="value" name="name" type="text">
<input name="name" value="value"type="text">
<input type="text" value="value" name="name">

 

This sounds like a case for back references.  But this is one of the things about regex that I've had the most trouble with.

Link to comment
https://forums.phpfreaks.com/topic/45188-getting-input-values/#findComment-219505
Share on other sites

I've got something that I think SHOULD work, but it's not.  In theory, it should look at every input and allow name & value to be at any position inside the angle brackets.

 

preg_match('/.*<input.+[[value="(.+)"|name="maxpop"]\s+]{1,2}.*>.*/imU',$response,$match);
echo "<pre>";
print_r($match);
echo "</pre>";

Link to comment
https://forums.phpfreaks.com/topic/45188-getting-input-values/#findComment-219535
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.