Results 1 to 3 of 3

Thread: Help! Newbie!

  1. #1
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Exclamation Help! Newbie!

    hi, i was wondering if any of u guys could help.
    i am trying to make a form for my site which is generally about facebook.
    the form is using the 'post' method but the 'action' section has got my head in a pickle.

    can anyone tell me how to create an 'action'?

    ideally, the data entered in the forms fields will be posted on the page for people to see!

    Form Fields: name, facebook profile url, gender and location.

    if anyone can help, it would be greatly appreciated!
    THANX!

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    <form method="POST/GET" action="SUBMITTOTHISPAGE.php">
    <input name="NAME" type="anything" value="VALUE">
    ....</form>


    1. method: use GET to submit IN the url; use POST to submit 'in the background'. In almost all cases POST is the smoother option (and also can allow for things like file uploads and long text). GET is rarely useful if you want to fit into a system that already uses page.php?somevariable=somevalue.

    2. action: this is where the data is sent and where the browser goes to-- it's like a link (but also with the form data). If you have your form on form.php and your receiving page on submit.php then form.php will redirect the user to submit.php when they submit the form. Then you can parse the sent data-- send an email, add it to a database, or do a search, etc... anything you want. You can also (because PHP can use if statements to serve different content) use a single page with variable output: the form, or if the form has been submitted use the same php page (that now displays the results, etc). That's a bit harder though.

    3. get the data in PHP: once the form is submitted, you can retrieve it like this:
    For each input the value will be in a $_GET or $_POST variable (based on method):
    $_GET['NAME'] = VALUE; and $_POST['NAME'] = VALUE';
    So the most basic example is echo $_POST['email']; which would output something like "test@example.com" or whatever they sent.
    (from <input type="text" name="email">)


    So in this sense forms are easy (after you do it once or twice): form html is pretty straightforward, the action is just to whichever page you want to use to get the data, and the php just grabs values from the form using $_GET and $_POST.
    The difficult part then becomes what you want to do with the data. Since you haven't specified that, let us know what that is or look up a tutorial on google. There are literally infinitely many things you can do with it, so that's the main reason it gets complex: but it also gives you the freedom to create whatever you want.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Default

    This is my form:

    <form name="add" action"" method="post" >
    <tr class="b">
    <td width="11%">&nbsp;Name:</td>
    <td width="38%"><input type="text" name="name" id="name" /></td>
    <td width="20%">&nbsp;Profile URL: </td>
    <td width="31%"><input name="profile" type="text" id="profile" size="15" />
    &nbsp;</td>
    </tr>
    <tr class="b">
    <td>&nbsp;Gender:</td>
    <td><select name="gender" id="gender">
    <option value="1" selected="selected">Male</option>
    <option value="2">Female</option>
    </select></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr class="b">
    <td>&nbsp;Location:</td>
    <td colspan="3"><label>
    <select name="location" size="1">
    (here there will be a list of different countries for location select, had to remove as post would be too long)
    </select>
    </label></td>
    </tr>
    <tr class="b">
    <td>&nbsp;</td>
    <td align="right"><input name="button3" type="submit" id="button" value="Request Friends" /></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    </form>
    action is left blank as i dont have an action yet.
    the plan is, to have all data entered in the fields, then have the entered data put into a table below for anyone to browse.

    your help is appreciated!

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
  •