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!
New to PHP. Help please
Moderator: General Moderators
Re: New to PHP. Help please
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.
Re: New to PHP. Help please
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.
Re: New to PHP. Help please
Try this and you will see what I mean,
Take care.
Code: Select all
<?php
$d=date("D");
echo "Today is $d";
?>