New to PHP. Help please

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
David S
Forum Newbie
Posts: 1
Joined: Tue Feb 17, 2009 1:19 pm

New to PHP. Help please

Post by David S »

I'm new to PHP and looking for help, please.

Can anyone tell me why the code below doesn't work? The form is saved as html and the php as weekend.php. I've uploaded to a server but all i get is Have a nice day, whatever is entered into the form.

<form action="weekend.php" method="post">
Date: <input type="text" name="date"><br>
<input type="submit" value="Submit">
</form>

<?php

$d=date("D");
if ($d=="Fri")
echo "Have a nice weekend!";
elseif ($d=="Sun")
echo "Have a nice Sunday!";
else
echo "Have a nice day!";
?>
Thanks!
User avatar
LanceEh
Forum Commoner
Posts: 46
Joined: Tue Feb 17, 2009 11:53 am
Location: Florida

Re: New to PHP. Help please

Post by LanceEh »

I'm rusty with my PHP and I'm trying to get back into it, but I think you need to assign the posted "date" variable to something. The $d=date("D"); looks wrong.
User avatar
LanceEh
Forum Commoner
Posts: 46
Joined: Tue Feb 17, 2009 11:53 am
Location: Florida

Re: New to PHP. Help please

Post by LanceEh »

The date function will always output what the server has. So if the server says it is Friday then date('D') will output 'Fri'. You can't change this.
User avatar
LanceEh
Forum Commoner
Posts: 46
Joined: Tue Feb 17, 2009 11:53 am
Location: Florida

Re: New to PHP. Help please

Post by LanceEh »

Try this and you will see what I mean,

Code: Select all

 
<?php
$d=date("D");
echo "Today is $d";
?>
 
Take care.
Post Reply