Page 1 of 1

calling php scripts...

Posted: Fri Nov 19, 2004 12:14 pm
by richcoleuk
i am trying to create an xhtml strict page. At the top i have a small piece of php code that will check the user has the required cookie (ie they've logged in) as soon as i include this code the page is a php page and therefore not valid xhtml. The php code is:

if($_COOKIE['logedin'] == NULL) {
header("Location: login.php");
exit();
}

how can i put this in a seperate php file then call it or run it from my xhtml page?

Posted: Fri Nov 19, 2004 12:29 pm
by peni
you don't have to, because only the output has to be validated. and the <?php ... ?> block is not a part of the output.
well, do you have <?php and ?> around your code-block at all?

Posted: Fri Nov 19, 2004 12:41 pm
by richcoleuk
i just had

<?

?>

do i need the php aswell?

Posted: Fri Nov 19, 2004 12:44 pm
by peni
yes, i think so.

Posted: Fri Nov 19, 2004 12:46 pm
by richcoleuk
yeah cheers solved it, thanks for the help

Posted: Fri Nov 19, 2004 12:48 pm
by MarK (CZ)
I'm not really sure what's your problem but I guess that you're trying to validate the php source code. Put into the validator instead the page which has been already generated by the server - so without the php code. PHP is not a part of xHTML.

EDIT: Seem to be late :)

Posted: Fri Nov 19, 2004 12:51 pm
by peni
anyway, right conclusion :)
[offtopic]greetings to praha, have been there a month ago, an amazing great city![/offtopic]

Posted: Fri Nov 19, 2004 12:55 pm
by MarK (CZ)
peni wrote:[offtopic]greetings to praha, have been there a month ago, a real great city![/offtopic]
Yeah, it is, the best one in the world! (ok, in Europe at least :) ).
Sorry for Image