943,741 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 667
  • PHP RSS
Nov 5th, 2008
0

need help with two simple php scripts

Expand Post »
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 Syntax (Toggle Plain Text)
  1. <?php
  2. if((H >= 06 && H < 08) || (H >= 18 && H < 20))include 'includes/iboerderij.php';
  3. elseif((H >= 08 && H < 10) || (H >= 20 && H < 22))include 'includes/inatuurlijk.php';
  4. elseif((H >= 10 && H < 12) || (H >= 22 && H < 00))include 'includes/ivijvers.php';
  5. elseif((H >= 12 && H < 14) || (H >= 00 && H < 02))include 'includes/iformeel.php';
  6. elseif((H >= 14 && H < 16) || (H >= 02 && H < 04))include 'includes/imodern.php';
  7. elseif((H >= 16 && H < 18) || (H >= 04 && H < 06))include 'includes/ioosters.php';
  8. ?>

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)
  1. <?PHP
  2. if ($_SERVER['REQUEST_METHOD'] == "POST")
  3. {
  4. echo "<div id=\"contactinf\">";
  5. if ((!$_POST['Name'] || !$_POST['Message'] || !$_POST['Email']))
  6. {
  7. echo 'u didnt fill everything in';
  8. }
  9. 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']))
  10. {
  11. echo "wrong e-mail address";
  12. }
  13. else
  14. {
  15. echo 'something';
  16. }
  17. echo "<div id=\"contact-area\">&nbsp;";
  18. }else
  19. {
  20. ?>
  21. <div id="contactinf">
  22. <p>
  23. something
  24. </p>
  25. <div id="contact-area">
  26. <form method="post"><label for="Name" id="Name">Naam:</label>
  27. <input type="text" name="Name" value="<?$_POST['Name']?>" />
  28. <label for="Email" id="Email">E-mail:</label>
  29. <input type="text" name="Email" value="<?$_POST['Email']?>"/>
  30. <label for="Message" id="Message">Bericht:</label><br />
  31. <textarea value="<?$_POST['Message']?>" name="Message" rows="20" cols="20"></textarea>
  32. <input type="submit" name="submit" value="Verzenden" class="submit-button" />
  33. </form>
  34. <?
  35. }
  36. ?>

i hope someone can help.
thanks in advance
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Modo is offline Offline
35 posts
since Oct 2008
Nov 5th, 2008
0

Re: need help with two simple php scripts

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 Syntax (Toggle Plain Text)
  1. <?php
  2. if((H >= 06 && H < 08) || (H >= 18 && H < 20))
  3. {include 'includes/iboerderij.php';}
  4. elseif((H >= 08 && H < 10) || (H >= 20 && H < 22))
  5. {include 'includes/inatuurlijk.php';}
  6. else((H >= 10 && H < 12) || (H >= 22 && H < 00))
  7. {include 'includes/ivijvers.php';}
  8. else((H >= 12 && H < 14) || (H >= 00 && H < 02))
  9. {include 'includes/iformeel.php';}
  10. else((H >= 14 && H < 16) || (H >= 02 && H < 04))
  11. {include 'includes/imodern.php';}
  12. else((H >= 16 && H < 18) || (H >= 04 && H < 06))
  13. {include 'includes/ioosters.php'; }
  14. ?>
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
jackakos is offline Offline
50 posts
since Sep 2008
Nov 5th, 2008
0

Re: need help with two simple php scripts

i tried this already before it didnt work ..
i tried it now again like u said .. it didnt work either
Reputation Points: 10
Solved Threads: 0
Light Poster
Modo is offline Offline
35 posts
since Oct 2008
Nov 5th, 2008
0

Re: need help with two simple php scripts

is H a defined variable?
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Nov 5th, 2008
0

Re: need help with two simple php scripts

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

Sorry it didn't work
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
jackakos is offline Offline
50 posts
since Sep 2008
Nov 5th, 2008
0

Re: need help with two simple php scripts

it says on the website of php H is time
Reputation Points: 10
Solved Threads: 0
Light Poster
Modo is offline Offline
35 posts
since Oct 2008
Nov 5th, 2008
0

Re: need help with two simple php scripts

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

try adding this to the top of the document:

PHP Syntax (Toggle Plain Text)
  1. define('H',date("H"));
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Nov 6th, 2008
0

Re: need help with two simple php scripts

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

do u have any tips for my second problem please?
Reputation Points: 10
Solved Threads: 0
Light Poster
Modo is offline Offline
35 posts
since Oct 2008
Nov 6th, 2008
0

Re: need help with two simple php scripts

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

Regards
Reputation Points: 14
Solved Threads: 0
Newbie Poster
psycho007 is offline Offline
23 posts
since Oct 2008
Nov 6th, 2008
0

Re: need help with two simple php scripts

i solved the second problem at school
i think i deleted something by mistake ..
thanks guys ..
Reputation Points: 10
Solved Threads: 0
Light Poster
Modo is offline Offline
35 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Need Help in doing reservation page for class project...:P
Next Thread in PHP Forum Timeline: Validate Input Fields





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC