| | |
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 |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube






