calling php scripts...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
richcoleuk
Forum Newbie
Posts: 24
Joined: Fri Nov 05, 2004 1:33 pm

calling php scripts...

Post 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?
peni
Forum Commoner
Posts: 34
Joined: Thu Nov 18, 2004 1:15 pm

Post 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?
richcoleuk
Forum Newbie
Posts: 24
Joined: Fri Nov 05, 2004 1:33 pm

Post by richcoleuk »

i just had

<?

?>

do i need the php aswell?
peni
Forum Commoner
Posts: 34
Joined: Thu Nov 18, 2004 1:15 pm

Post by peni »

yes, i think so.
richcoleuk
Forum Newbie
Posts: 24
Joined: Fri Nov 05, 2004 1:33 pm

Post by richcoleuk »

yeah cheers solved it, thanks for the help
User avatar
MarK (CZ)
Forum Contributor
Posts: 239
Joined: Tue Apr 13, 2004 12:51 am
Location: Prague (CZ) / Vienna (A)
Contact:

Post 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 :)
peni
Forum Commoner
Posts: 34
Joined: Thu Nov 18, 2004 1:15 pm

Post by peni »

anyway, right conclusion :)
[offtopic]greetings to praha, have been there a month ago, an amazing great city![/offtopic]
User avatar
MarK (CZ)
Forum Contributor
Posts: 239
Joined: Tue Apr 13, 2004 12:51 am
Location: Prague (CZ) / Vienna (A)
Contact:

Post 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
Post Reply