• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

Form method post action to url, html tags have id. Enough?

Hi,

I have a form having id, action to url and post method. I have my html tags having ids. So are those enough that the target page will grab the values on those html tags via the ids' of those tags?

Regards.
0
jazzIIIlove
Asked:
jazzIIIlove
  • 3
  • 3
  • 2
  • +2
5 Solutions
 
käµfm³d 👽Commented:
For input controls to be posted back to the server from a form, you need to assign each relevant input control a name, not an id. id is used for Javascript to locate elements in the DOM, though name can be used for the same.
0
 
Marco GasiFreelancerCommented:
So are those enough that the target page will grab the values
I'm not sure to understand this question: ids apart, if in the target you page use an appropriate php script to process form values, yes, your form contains data enough.
0
 
jazzIIIloveAuthor Commented:
Wait, so 'name' is a must?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
käµfm³d 👽Commented:
Wait, so 'name' is a must?
If you want the browser to send the data to the server...yes. That is, unless you are working some Javascript kung-fu into your page to submit the data programmatically.
0
 
Dave BaldwinFixer of ProblemsCommented:
I don't think you can count on 'id's being enough.  I use both 'name' and 'id' on all my tags in my HTML forms.  Javascript in particular likes the 'id's better.  It is difficult using the 'name' in javascript.
0
 
Ray PaseurCommented:
Yes, the 'name' is a must.  It becomes the array index into the request array, $_GET or $_POST.  This script illustrates the essential moving parts of an HTML form and a PHP action script.
http://www.iconoun.com/demo/form_thankyou_page.php

<?php // demo/form_thankyou_page.php
error_reporting(E_ALL);
echo "<pre>";


// SHOW HOW TO DO FORM INPUT, VALIDATION, AND THANK YOU PAGE


// IF THERE IS SOMETHING THAT HAS BEEN POSTED
if (!empty($_POST))
{

    // THIS IS THE VALIDATION PROCESS - ONLY TWO RESULTS
    // EITHER A FAILURE PAGE OR A THANK YOU PAGE
    // CHECK TO SEE IF IT IS WHAT WE EXPECT
    if ($_POST["xyz"] != 'XYZ')
    {
        // CREATE ERROR PAGE IF DATA FAILED VALIDATION
        echo PHP_EOL . "SORRY YOU DID NOT ENTER XYZ";
    }
    else
    {
        // CREATE THANK YOU PAGE IF DATA PASSED VALIDATION
        echo PHP_EOL . "THANK YOU, ";
        die("ALL DONE NOW");
    }

}
// END OF PHP - DROP INTO HTML TO PUT UP THE FORM
?>
<form method="post">
ENTER 'XYZ' IN UPPER CASE LETTERS HERE:
<input name="xyz" />
<input type="submit" />
</form>

Open in new window

0
 
jazzIIIloveAuthor Commented:
Thanks guys.

Just as the old days in EE :)

I have a related question here.

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/HTML/Q_28374777.html
0
 
jazzIIIloveAuthor Commented:
Glad to see the best gang in EE :)
0
 
Ray PaseurCommented:
Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now