Form Fields (Elements) ?

Discussion in 'PHP' started by kashifkb, May 31, 2007.

  1. #1
    Hi there,

    I want a tool that gets the values (elements) of a form.

    Can anyone please provide me that kind of utility.

    I will be really thankful.

    Best Regards
    KB
     
    kashifkb, May 31, 2007 IP
  2. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #2
    Can you clarify your question please???
    You can use a foreach loop on the $_GET or $_POST variables
     
    nabil_kadimi, May 31, 2007 IP
  3. rgchris

    rgchris Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah, what he said.

    Form:

    <form method = 'post' action = 'example.php'>
    <input type = 'text' name = 'name'>
    <input type = 'text' name = 'email'>
    <input type = 'submit' value = 'Submit'>
    </form>
    Code (markup):
    Display values:

    foreach($_POST as $value)
    {
         echo $value . "<br />";
    }
    
    PHP:
    Something like that.
     
    rgchris, May 31, 2007 IP
  4. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #4
    sounds to me like you need $_POST or $_GET

    here's the man pages
    us2.php.net/manual/en/reserved.variables.php#reserved.variables.post
    us2.php.net/manual/en/reserved.variables.php#reserved.variables.get

    here's an example of looping through the $_POST / $_GET vars submitted by a page:
    
    <?php
        if ($_POST)
        {
            foreach ($_POST as $key => $value)
            {
                echo "NAME: ".$key.", VALUE: ".$value."<br />";
            }
        }
        else
        {
            echo "no $_POST vars found. checking $_GET...<br /><br />";
    
            if($_GET)
            {
                foreach ($_GET as $key => $value)
                {
                    echo "NAME: ".$key.", VALUE: ".$value."<br />";
                }
            }
            else
            {
                echo "no $_GET vars found.";
            }
        }
    ?>
    
    Code (markup):
     
    ansi, May 31, 2007 IP
  5. kashifkb

    kashifkb Banned

    Messages:
    205
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi there,

    Actually I am working on a web based application for submitting the websites in the web directories.

    Web directories contain forms and I want to get the values of these forms with the help of a tool.

    If I have 1000 web directories then it will not be possible for me to manually get the values from each form.

    So I immediately require a tool to get the field values of the forms.

    I will really appreciate any help.

    Best Regards
    KB
     
    kashifkb, May 31, 2007 IP
  6. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #6
    well it could be done with some regexp and scraping the pages but it's not something that i want to write for you... :)
     
    ansi, May 31, 2007 IP
  7. Aragorn

    Aragorn Peon

    Messages:
    1,491
    Likes Received:
    72
    Best Answers:
    1
    Trophy Points:
    0
    #7
    As ansi said, you can either use a purely serverside solution using regexp or else you can use both serverside and clientside. All I can give is a rough idea
    * Get the content of the page using serverside, insert the required javascript into it and echo it.
    * The javascript will collect info about the required fields and send you the details using an ajax request.
    * Then the page gets redirected to the next page to get the content of the new page.
     
    Aragorn, May 31, 2007 IP
  8. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #8
    sounds like his best bet to me. i like the part about using javascript to get the values of the form fields. there could be millions of patterns to match all the sites that he requests but with javascript gathering all the values and stuff, it would be a breeze.
     
    ansi, Jun 1, 2007 IP
  9. projectshifter

    projectshifter Peon

    Messages:
    394
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #9
    It wouldn't hurt to grab a full list of the $_POST and $_GET variables and store them and you can just have a script sift through them and put things together like $_POST['name'] and $_POST['fullname'] are the same, etc.
     
    projectshifter, Jun 1, 2007 IP
  10. Aragorn

    Aragorn Peon

    Messages:
    1,491
    Likes Received:
    72
    Best Answers:
    1
    Trophy Points:
    0
    #10
    I think you got the idea wrong. What he want is to get the available form fields and types in another page.
     
    Aragorn, Jun 1, 2007 IP
  11. projectshifter

    projectshifter Peon

    Messages:
    394
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Ah gotcha, been up all night, a little out of it :( Regular expressions might not be a bad idea in that case.
     
    projectshifter, Jun 1, 2007 IP