Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
name deprecated $_post['']
Old 12-18-2008, 10:45 PM name deprecated $_post['']
Average Talker

Posts: 29
Name: Taylor
Trades: 0
Since the name attribute has been deprecated in xhtml how does one go about getting post form data without using the name attribute??

Thanks
Raisdead is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-19-2008, 03:11 AM Re: name deprecated $_post['']
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
The id attribute
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-19-2008, 01:04 PM Re: name deprecated $_post['']
Average Talker

Posts: 29
Name: Taylor
Trades: 0
then Why does the following not work..

<?php
echo "name: ".$_POST['name'];
?>


<form id=\"reg\" action=\"register.php\">
<input type=\"text\" id=\"name\" /><hr />
<input type=\"submit\" value=\"Register\"/>
</form>
Raisdead is offline
Reply With Quote
View Public Profile
 
Old 12-19-2008, 01:33 PM Re: name deprecated $_post['']
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
because the $_POST['name']; will display the content of the input field with the name of "name".
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 12-19-2008, 03:24 PM Re: name deprecated $_post['']
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
eventually server side code may catch up with the plan that the ID attribute can also be used as a form key\value pair.

But don't hold your breath.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-19-2008, 03:35 PM Re: name deprecated $_post['']
Novice Talker

Posts: 6
Location: Oklahoma
Trades: 0
Out of curiousity, why would you not want to use the name attribute?
phpgator is offline
Reply With Quote
View Public Profile Visit phpgator's homepage!
 
Old 12-19-2008, 04:02 PM Re: name deprecated $_post['']
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
oh and another thing to reaisdead

if you make the form pass to its self you could do something like this:

PHP Code:
<?php
$name 
$_POST['username'];
$age $_POST['age'];
if (isset(
$name) and isset($age)) {
     print 
"Hello, $name.<br />You are $age year(s) old.\n";
} else {
     
$self $_SERVER['PHP_SELF'];
     print 
"<form action='$self method='post'>\n";
     print 
"<input type='text' name='username' value='$name' />\n";
     print 
"<input type='text' name='age' value='$age' />\n";
     print 
"<input type='submit' value='submit' /></form>\n";
}
?>
This would post the information back to the form, if you forgot to fill out your age or name.

enjoy!

*EDIT* Yes, i know that i could have done the fancy ">>>" thing, but i prefer to print it like this.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 12-20-2008, 12:38 AM Re: name deprecated $_post['']
Average Talker

Posts: 29
Name: Taylor
Trades: 0
I want my page to be valid xhtml therefore i cannot have the name attribute.

None of your responses actually solved my problem

other than change it to the name attrube is there anything I can to to make sure the server passes the id attribute to the post request.
Raisdead is offline
Reply With Quote
View Public Profile
 
Old 12-20-2008, 04:34 AM Re: name deprecated $_post['']
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
What version of XHTML are you using? I mostly use 1.0 Transitional and I have no problems with the name attribute.

There's not a whole lot you can do in this case. If you look at the XHTML syntax as described at w3schools you'll notice that there is a recommendation to include both the name and id attributes with identical values in order to maximize compatibility.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-20-2008, 04:58 AM Re: name deprecated $_post['']
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Yep, Just use transitional for the form pages.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-20-2008, 08:36 AM Re: name deprecated $_post['']
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
It's my understanding that the name attribute is only deprecated for elements other than <input>. I just validated one of my XHTML Strict pages that uses "name" on inputs to confirm this. There were no errors related to "name" in the validation. "Name" was once used on many elements. Now, it is only supposed to be proper to use it on form elements.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 12-21-2008, 06:20 PM Re: name deprecated $_post['']
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
It's my understanding that the name attribute is only deprecated for elements other than <input>. I just validated one of my XHTML Strict pages that uses "name" on inputs to confirm this. There were no errors related to "name" in the validation. "Name" was once used on many elements. Now, it is only supposed to be proper to use it on form elements.
Thats what i was thinking :/ i only ever use name for inputs and most of the pages I do are XHTML strict 1.0

__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 12-22-2008, 11:33 AM Re: name deprecated $_post['']
Average Talker

Posts: 29
Name: Taylor
Trades: 0
Thanks a bunch ill try those things
Raisdead is offline
Reply With Quote
View Public Profile
 
Old 12-22-2008, 11:53 AM Re: name deprecated $_post['']
Average Talker

Posts: 29
Name: Taylor
Trades: 0
For your information its also name attribute is also not deprecated in the <select> tag.
Raisdead is offline
Reply With Quote
View Public Profile
 
Old 12-22-2008, 11:54 AM Re: name deprecated $_post['']
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
or the <textarea> tag....
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 12-22-2008, 09:38 PM Re: name deprecated $_post['']
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
can we just say the name tag isnt deprecated in form elements?

lol
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 12-23-2008, 03:55 AM Re: name deprecated $_post['']
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
No, that would be just silly and far too obvious.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-23-2008, 05:55 AM Re: name deprecated $_post['']
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
I want my page to be valid xhtml therefore i cannot have the name attribute.

None of your responses actually solved my problem

other than change it to the name attrube is there anything I can to to make sure the server passes the id attribute to the post request.
To correct this, you would need to follow the same path than when the target property was reimplemented using javascript:
Code:
var aryElm=document.getElementByTagName('input')
for(cptElm=0;cptElem<aryElm.length;cptElm++){
  elm=aryElm[cptElm];
  elm.name=elm.id;
}
Like this, your xhtml is valid, and the browser will alter it on load time to re-create the name attribute.

Messy, but if xhtml validation is that much important to you and the deprecation to transitional is out of the equation, your only route...
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to name deprecated $_post['']
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.50645 seconds with 12 queries