Page 1 of 1
HTML files included PHP inside
Posted: Wed Jun 23, 2004 2:17 am
by fuyenhou
I had developed a web site with HTML files
Then i would like to add in PHP program into the web site
Hm.. for example
I had create a cookie inside a xxx.php fields an examples --
setcookie("username",$username);
thus I would like to display in HTML pages
<html>
<head> try </head>
<body>
'I had insert alot of fixed image and also flash inside this HTML page
then in the means tims I need these cookie help to disply the information so i write
---CODE CODE
you are: <?php echo $_COOKIE["username"] ?;>
</body>
</html>
Nothing show out.. wat can I do... HELP
TOLONG in malay
?>[/php_man]
Posted: Wed Jun 23, 2004 2:26 am
by feyd
first off, make sure display_errors is turned on, make sure error_reporting is E_ALL.
if you are using any code that affects headers (cookies, sessions, header function calls) they must happen prior to any output, be it text, whitespace, anything; otherwise, you will get errors and warnings about headers being already sent, which will make your cookie/sessions/header calls not work. read
Warning: Cannot add header information for additional information about the errors, and how to fix them.
next, make sure to read
Posting Code in the Forums for our guidelines about posting bits of code/output what have you.
Finally, it is suggested that you do all php processing outside of "presentation" level things. In other words, 99.9999% of your php code should occur prior to any HTML. This is mostly to get the greatest seperation from the HTML and php as possible. The reason for this, is the page design will change, how the code works (behind the scenes) shouldn't change much at all in respect to the changing design. Plus, a designer can be working on the HTML while a programmer can work on the code without any overstep. Which is always productive.
Posted: Wed Jun 23, 2004 10:17 am
by d3ad1ysp0rk
Also, a more obvious solution, if you're setting the cookie on the same page as you're trying to display it, then it won't show up.
Try this:
process.php:
Code: Select all
<?php setcookie("username",$username);
header("Location:display.php"); ?>
display.php:
Code: Select all
<html>
<head> try </head>
<body>
'I had insert alot of fixed image and also flash inside this HTML page
then in the means tims I need these cookie help to disply the information so i write
---CODE CODE
you are: <?php echo $_COOKIE["username"] ?;>
</body>
</html>
Posted: Wed Jun 23, 2004 10:53 am
by Illusionist
If i followed what you said, you actually have your PHP in an .html file?? If so, then you would need to set up PHP to parse .html files aswell so it will execute the PHP code inside, if that makes any sense!