Solved

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

Posted on 2014-02-25
10
338 Views
Last Modified: 2014-02-26
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
Comment
Question by:jazzIIIlove
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 200 total points
ID: 39886935
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
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39886957
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
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 39886969
Wait, so 'name' is a must?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 39886974
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 200 total points
ID: 39886979
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
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
ID: 39887005
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
 
LVL 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 39887007
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
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 39888341
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
 
LVL 12

Author Closing Comment

by:jazzIIIlove
ID: 39888342
Glad to see the best gang in EE :)
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39888867
Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

827 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question