Solved

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

Posted on 2014-02-25
10
333 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 74

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 30

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 74

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 82

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
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 …

757 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

25 Experts available now in Live!

Get 1:1 Help Now