hi guys how r u doing ..
i need some help .. something went wrong and i dunno what is going on ..
i will post the problems .. i hope someone could help

first i tried making a script .. to include certain files depending on the time ...

<?php
if((H >= 06 && H < 08) || (H >= 18 && H < 20))include 'includes/iboerderij.php';
elseif((H >= 08 && H < 10) || (H >= 20 && H < 22))include 'includes/inatuurlijk.php';
elseif((H >= 10 && H < 12) || (H >= 22 && H < 00))include 'includes/ivijvers.php';
elseif((H >= 12 && H < 14) || (H >= 00 && H < 02))include 'includes/iformeel.php';
elseif((H >= 14 && H < 16) || (H >= 02 && H < 04))include 'includes/imodern.php';
elseif((H >= 16 && H < 18) || (H >= 04 && H < 06))include 'includes/ioosters.php';	
?>

it seemed to be working first .. but now it ONLY display inatuurlijk.php
any ideas why? i tried echoing the time .. and i can see the time is just like
my local time .. which means there is something wrong with my script.


second problem .. is that i tried running some validation for a form with php.
i didnt write the whole script. i got idea's here and there.
it was working in the morning and now it keeps echoing the e-mail
address that i entered is wrong. it keeps saying that. although in the morning
it only did if the e-mail address was missing a @ for example ..

<?PHP
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
echo "<div id=\"contactinf\">";
if ((!$_POST['Name'] || !$_POST['Message'] || !$_POST['Email']))
{					
echo 'u didnt fill everything in'; 
}
elseif (!preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/', $_POST['Email']))
{
echo "wrong e-mail address";
}
else 
{
echo 'something';
}
echo "<div id=\"contact-area\">&nbsp;";	
}else
{
?>
<div id="contactinf">
<p>
something
</p>
<div id="contact-area">	
<form method="post"><label for="Name" id="Name">Naam:</label>
<input type="text" name="Name" value="<?$_POST['Name']?>" />
<label for="Email" id="Email">E-mail:</label>
<input type="text" name="Email" value="<?$_POST['Email']?>"/>
<label for="Message" id="Message">Bericht:</label><br />
<textarea value="<?$_POST['Message']?>" name="Message" rows="20" cols="20"></textarea>
<input type="submit" name="submit" value="Verzenden" class="submit-button" />
</form>
<?
}
?>

i hope someone can help.
thanks in advance

Looks like you will need to tidy the first part by including braces and also look at the structure of the if elseif else statement.

Your code should be

<?php
if((H >= 06 && H < 08) || (H >= 18 && H < 20))
{include 'includes/iboerderij.php';}
elseif((H >= 08 && H < 10) || (H >= 20 && H < 22))
{include 'includes/inatuurlijk.php';}
else((H >= 10 && H < 12) || (H >= 22 && H < 00))
{include 'includes/ivijvers.php';}
else((H >= 12 && H < 14) || (H >= 00 && H < 02))
{include 'includes/iformeel.php';}
else((H >= 14 && H < 16) || (H >= 02 && H < 04))
{include 'includes/imodern.php';}
else((H >= 16 && H < 18) || (H >= 04 && H < 06))
{include 'includes/ioosters.php';	}
?>

i tried this already before it didnt work ..
i tried it now again like u said .. it didnt work either

May be you need to wait for some of the Gurus to have a look.

Sorry it didn't work

H is not a predefined variable by php that i know of.

try adding this to the top of the document:

define('H',date("H"));

thanks a lot .. this solved my first problem ..

do u have any tips for my second problem please?

try the case statement, this would make things alot easier to code and to read.

Regards

i solved the second problem at school
i think i deleted something by mistake ..
thanks guys ..

This article has been dead for over six months. Start a new discussion instead.