Php greeting in my html homepage?

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
Sanneza
Forum Newbie
Posts: 1
Joined: Mon Jan 11, 2010 5:47 am

Php greeting in my html homepage?

Post 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:
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: Php greeting in my html homepage?

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Php greeting in my html homepage?

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: Php greeting in my html homepage?

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