| | |
need help with two simple php scripts
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2008
Posts: 35
Reputation:
Solved Threads: 0
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 ...
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 ..
i hope someone can help.
thanks in advance
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 Syntax (Toggle Plain Text)
<?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 Syntax (Toggle Plain Text)
<?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\"> "; }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
Your code should be
php Syntax (Toggle Plain Text)
<?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'; } ?>
It is NO SHAME to ask when you want to LEARN, but FOOLISH to behave knowledgeable when YOU DON'T.
Keep PEACE alive!
Keep PEACE alive!
H is not a predefined variable by php that i know of.
try adding this to the top of the document:
try adding this to the top of the document:
PHP Syntax (Toggle Plain Text)
define('H',date("H"));
![]() |
Similar Threads
- Simple PHP Cart (PHP)
- Help on Simple PHP Form (PHP)
- PHP newbie (PHP)
- generating txt using php (PHP)
- Just a simple question. (PHP)
- php flash mail (PHP)
- question about connecting odbc to sql through php script (PHP)
- Apache on linux OS, running PHP scripts (Linux Servers and Apache)
Other Threads in the PHP Forum
- Previous Thread: Need Help in doing reservation page for class project...:P
- Next Thread: Validate Input Fields
| Thread Tools | Search this Thread |
.htaccess action ajax apache api array auto beginner binary bounce broken cakephp checkbox class cms code cron curl database date display dynamic echo email error errorlog file files folder form format forms function functions google href htaccess html image include insert integration interactive ip java javascript joomla limit link login loop mail malfunctioning masterthesis menu mlm mod_rewrite multiple mysql nodes oop paypal pdf php popup problem query radio ram random recursion reference regex remote return script search server sessions sms soap source space sql syntax system table tutorial unset update upload url validation validator variable video web websitecontactform xml youtube






