Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Problem With Xhtml Validation
TavoxPeru
post Feb 2 2007, 04:19 AM
Post #1


Super Member
Group Icon

Group: [HOSTED]
Posts: 796
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579
myCENTs:26.78



Hi, i have a problem when i try to validate a php page that includes a litlle form and use sessions as a strict xhtml 1.1 page with the W3C XHTML VALIDATOR, the problem consists that everytime i send it to the validator it creates a hidden input with the PHP PHPSESSID in the form and also adds to the href attribute of every link this PHPSESSID, so if you have for example a link like this:
CODE
<a href="page.php?sessionvar=1">page with session var equal 1</a>

it results in this:
CODE
<a href="page.php?sessionvar=1&PHPSESSID=Some_Value">page with session var equal 1</a>

and as you know it is recommended that always replace & with &amp; to make your page valid XHTML 1.1

Can someone knows a solution for this????

Best regards,
Go to the top of the page
 
+Quote Post
Quatrux
post Feb 2 2007, 02:18 PM
Post #2


the Q
Group Icon

Group: [HOSTED]
Posts: 1,094
Joined: 13-July 05
From: Lithuania, Vilnius
Member No.: 7,059
myCENTs:70.96



The solution is easy, you need to make the & into &amp; and for your situation I find it very easy to use htaccess files and I recommend to put that file into your account root dir, you need to change the php.ini settings, overdrive them. wink.gif
CODE

#=====================================\
# ARG SEPERATOR OUTPUT value (String) +
#=====================================/
php_value arg_separator.output "&amp;"


So this should work, if I understood correctly that the & is created by the server and I also recommend to program in a way, that to avoid the PHPSESSID in the GET. wink.gif
Go to the top of the page
 
+Quote Post
TavoxPeru
post Feb 3 2007, 03:27 AM
Post #3


Super Member
Group Icon

Group: [HOSTED]
Posts: 796
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579
myCENTs:26.78



QUOTE(Quatrux @ Feb 2 2007, 09:18 AM) *

The solution is easy, you need to make the & into & and for your situation I find it very easy to use htaccess files and I recommend to put that file into your account root dir, you need to change the php.ini settings, overdrive them. wink.gif
CODE

#=====================================\
# ARG SEPERATOR OUTPUT value (String) +
#=====================================/
php_value arg_separator.output "&"


So this should work, if I understood correctly that the & is created by the server and I also recommend to program in a way, that to avoid the PHPSESSID in the GET. wink.gif

Thanks a lot, i found this solution too after a small research biggrin.gif but also i found other problem related with this, especially if you send your forms with the POST method, because the server include a hidden input with the PHPSSID value to every form included in the page.

Now, i found that there is two easy ways to solve this problem.
  1. You must use the ini_set php function to set the url_rewriter.tags and the arg_separator.output in every php page that you want to be valid xhtml1.1 as the following code:

    CODE
    <?php
    ini_set("arg_separator.output","&");
    ini_set("url_rewriter.tags","a=href,area=href,frame=src,input=src");
    ?>

  2. To the htaccess file that Quatrux post you must add the following line: php_value url_rewriter.tags "a=href,area=href,frame=src,input=src"

    So the complete htaccess file will be:
    CODE
    <IfModule mod_php4.c>
      php_value arg_separator.output "&"
      php_value url_rewriter.tags "a=href,area=href,frame=src,input=src"
    </IfModule>

    And in every form of every php page that you want to be valid xhtml1.1 you must include a hidden input:
    CODE
    <input type="hidden" name="PHPSESSID" value="<?php echo session_id();?>" />

    I dont test this solution with PHP5 but i think it would work too, so i will test it and edit this post with the results very soon.
Finally, i recommend the use of the second option, because it this way you only have to include the hidden input to your pages.

BTW, this problem was a recognized PHP bug as noticed in the PHP website: Bug #13472 input type=hidden should be in a fieldset if there is one (XHTML and trans sid)

Best regards,
Go to the top of the page
 
+Quote Post
FirefoxRocks
post Feb 24 2007, 04:00 PM
Post #4


Super Member
Group Icon

Group: [HOSTED]
Posts: 738
Joined: 12-July 06
From: Ontario, Canada
Member No.: 14,464



Could you please explain that in more simpler terms? I finally whipped up a login script and I am encountering that problem too. I have tried adding <div> to many places, but the <input type="hidden"> thing comes up RIGHT AFTER the <form> thing, therefore <div>s are kind of useless there.

I need to have pages validate as XHTML 1.0 Strict. XHTML 1.1 requires the application/xhtml+xml MIME type which is difficult to configure for Internet Explorer sad.gif.
Go to the top of the page
 
+Quote Post
TavoxPeru
post Feb 24 2007, 09:58 PM
Post #5


Super Member
Group Icon

Group: [HOSTED]
Posts: 796
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579
myCENTs:26.78



QUOTE(FirefoxRocks @ Feb 24 2007, 11:00 AM) *
Could you please explain that in more simpler terms? I finally whipped up a login script and I am encountering that problem too. I have tried adding <div> to many places, but the <input type="hidden"> thing comes up RIGHT AFTER the <form> thing, therefore <div>s are kind of useless there.

I need to have pages validate as XHTML 1.0 Strict. XHTML 1.1 requires the application/xhtml+xml MIME type which is difficult to configure for Internet Explorer sad.gif.

As i said in my previous post, there are 2 easy ways to solve this problem, i prefer the second option -using a htaccess file- because you do it only one time and forget, it will apply to all the webpages of your site.

So your first step is to create a htaccess file and upload it to your root folder with the following:

CODE
php_value arg_separator.output "&"
php_value url_rewriter.tags "a=href,area=href,frame=src,input=src"

Then, your next step is to add to every of your pages that uses forms a hidden input named PHPSESSID with the session_id php function as its value, you do it with the following:

CODE
<input type="hidden" name="PHPSESSID" value="<?php echo session_id();?>" />

If you need more help with this please let me know and i can send you a complete example.

Best regards,
Go to the top of the page
 
+Quote Post
FirefoxRocks
post Feb 24 2007, 10:14 PM
Post #6


Super Member
Group Icon

Group: [HOSTED]
Posts: 738
Joined: 12-July 06
From: Ontario, Canada
Member No.: 14,464



Where do I insert this?
HTML
<input type="hidden" name="PHPSESSID" value="<?php echo session_id();?>" />


My best guess is in the form thing but I'm not sure.
Go to the top of the page
 
+Quote Post
TavoxPeru
post Feb 24 2007, 10:33 PM
Post #7


Super Member
Group Icon

Group: [HOSTED]
Posts: 796
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579
myCENTs:26.78



QUOTE(FirefoxRocks @ Feb 24 2007, 05:14 PM) *
Where do I insert this?
HTML
<input type="hidden" name="PHPSESSID" value="<?php echo session_id();?>" />


My best guess is in the form thing but I'm not sure.

Yes, you insert it inside your form, for example something like this will work fine:

CODE
<form action="page.php" method="post">
<p>
<label for="email">Your email:</label><input id="email" name="email" /> <input type="submit" value="Submit" /><input type="hidden" name="PHPSESSID" value="<?php echo session_id();?>" style="display:none" />
</p>
</form>

BTW, you can put the hidden input wherever you want in your form and with the display:none style applied to it you tell the browser that you don't allocate any space to the hidden input, remove it to see the diference. Also you can replace the p tag with a div tag if you want.

Best regards,
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Converting HTML over to XHTML(13)
  2. Help! Problem With My Flash-Drive(2)
  3. Error 406 - Problem In My Phpbb Forum(8)
  4. Ip Problem(8)
  5. Understanding Xhtml(8)
  6. MSN Help(5)
  7. ATI Video Card Problem! Need Help(5)
  8. PHP Tutorial: Form Verification And Simple Validation(12)
  9. Problem Accessing My Cpanel(9)
  10. Einstein Quiz(30)
  11. Photoshop Cropping Problem(7)
  12. Need To Hack An Admin Account On Xp... No Problem!(61)
  13. Blue Screen - irql_not_less_or_equal(35)
  14. Spam Problem On My Forums(26)
  15. Frustrating Problem With XP On Laptop(20)
  1. Problem With Drag And Drop (or So It Seems).(12)
  2. Win Rar Password Problem(7)
  3. Fedora Core 6 Install Problem(6)
  4. Trojan / Virus Problem ,please Help(18)
  5. A Gaiaonline Problem(9)
  6. Administrator Account Problem In Microsoft Xp [solved](20)
  7. Good Book For Learning Xhtml & Css(2)
  8. Problem With Div's In Ie6 And Lower(4)
  9. Pc Problem(8)
  10. Graphics Driver Out...(2)
  11. How To Validate The Login Form Using Php Pcre(0)
  12. Problem Setting Up Wireless Internet & Wireless Nintendo Wii(4)
  13. System Is Crashed - Hardware Problem(3)


 



- Lo-Fi Version Time is now: 23rd November 2008 - 12:24 AM