Problem With Xhtml Validation

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Problem With Xhtml Validation

TavoxPeru
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,

Reply

Quatrux
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

Reply

TavoxPeru
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,

 

 

 


Reply

FirefoxRocks
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.

Reply

TavoxPeru
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,

Reply

FirefoxRocks
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.

Reply

TavoxPeru
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,

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : xhtml validation

  1. Xhtml Validation With Php In Cgi Mode - (0)
  2. A Simple Checking & Validation PHP Script - (6)
    Hi, there is sometimes that you need to password protect a directory in your site but you dont have
    access to a database or you dont need it because only a few users will access this directory, well
    the following script i develop will help in this situation. With only 2 files you can implement a
    basic security, the first file is a simple txt file where you store your users information and the
    second file is the php script. You can name the files whatever you want and can be used in any site
    with php support. The users.txt file: In this file simply put one line at the...
  3. How Do I Do Script Checking & Validation In PHP? - (17)
    I'm totally new to all this, and I've just done a registration/login script. It has 5
    different files that I put stuff in, plus a database. When I try to see how it looks on my website,
    well, it just doesn't show up. What I want to know is, how can I tell what I'm doing wrong?
    I don't always understand what the editors in the script programs are trying to say. Is there
    anyone out there who can help? My scripts are written in PHP with a MySql database. Boy, this all
    gets confusing, but I sure love every minute of it!...
  4. Detecting XHTML + XML In Browsers - Can it be improved? (1)
    I have written a script to detect if the mime-type application/xhtml+xml is supported in browsers,
    yet some browsers that do support this mime-type have to be tested manually so I was wondering
    whether there was a better method. Something I would rather do is intercept the browser before it
    decides to download the page instead, is this possible? Here's the script I wrote, which
    detects strings from the User Agent, it's just a small snippet of it: CODE // function to
    test for application/xhtml+xml mime-type support function CheckXHTML() {  // For Robots,...
  5. Simple E-mail Validation - check for correct address and syntax (2)
    Hey , this tutorial will tell you a very simple way to check if email addresses entered are with the
    correct syntax. Hope this will help you eliminate jokers. So this script will... (check the
    characters, and check if there is a " someone somewhere.extension ". Ok, so firstly we create a
    function with all the invalid stuff in it:- CODE function CheckMail($email) { if (eregi("^ (
    ? )*@ ( ? )*\. {2,4}$", $email)) { return true; } else { return false; } } Now, to check an
    email you just run the variable with the email in it through the function as foll...
  6. Form Validation - Javascript (10)
    Okay, I know how to use cgi or php to make sure a form is filled out the way I want, and if not,
    post up a page marking what needs to be fixed. I also know how to make a javascript to alert what
    needs to be fixed and not procede until they are fixed. What I want to do is use javascript to mark
    everything that needs to be fixed without using alerts, probably by changing the color. Any ideas
    as to how to do this?...



Looking for problem, xhtml, validation






*SIMILAR VIDEOS*
Searching Video's for problem, xhtml, validation
advertisement




Problem With Xhtml Validation



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE