Page 1 of 1

Php greeting in my html homepage?

Posted: Mon Jan 11, 2010 5:51 am
by Sanneza
I've been having some trouble trying to find out how to do this:

I would like to put a greeting on the front page of my home page, using php with the ‘if.. else if’ statements
I got the idea from this tut:
http://www.w3schools.com/php/php_if_else.asp
(If you didn’t peek the link;
If its Friday the greeting would say ‘Have a nice weekend’
If it’s a normal weekday it would say ‘Have a nice day’ etc.)

But (yes there’s always a but, that’s why I will greatly appreciate any help) my homepage is HTML, and php is new to me
-Do you have any suggestions? Or is it simply not possible?
Thanks in advance! <3 :D


P.S -This is my first post, hi all :mrgreen:

Re: Php greeting in my html homepage?

Posted: Mon Jan 11, 2010 5:59 am
by aravona
You can post a section of php into your html file, it is allowed :)

If you've got your code already it can sit inside your html like this:

Code: Select all

<html>
<body>
[b]<?php
    echo gmdate("M d Y");
?>[/b]
</body>
</html>
exactly like in the tutorial if you want it at the top of your page etc, just put it at the top of your body you can use html to control the php as well (I have within html forms etc) if you want your code double checked post it up

PS: hi :D

Re: Php greeting in my html homepage?

Posted: Mon Jan 11, 2010 9:32 am
by AbraCadaver
Yes, but most likely your homepage file will need the .php extension unless you control the server and configure the .html/.htm extension to be parsed by PHP.

Re: Php greeting in my html homepage?

Posted: Mon Jan 11, 2010 9:36 am
by aravona
AbraCadaver wrote:Yes, but most likely your homepage file will need the .php extension unless you control the server and configure the .html/.htm extension to be parsed by PHP.

Thats true, I forgot about that. Though it wont make a difference to the html in the page at all (I once got given a website to alter, all the pages were .php but none of them contained any php at all just html!)