Solved

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

Posted on 2014-02-25
10
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 110

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 110

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 110

Expert Comment

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

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

691 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