Solved

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

Posted on 2014-02-25
10
336 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
 
LVL 108

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 108

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 108

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now