need help with two simple php scripts

Reply

Join Date: Oct 2008
Posts: 35
Reputation: Modo is an unknown quantity at this point 
Solved Threads: 0
Modo Modo is offline Offline
Light Poster

need help with two simple php scripts

 
0
  #1
Nov 5th, 2008
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 ...

  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 ..



  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
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 50
Reputation: jackakos is an unknown quantity at this point 
Solved Threads: 0
jackakos's Avatar
jackakos jackakos is offline Offline
Junior Poster in Training

Re: need help with two simple php scripts

 
0
  #2
Nov 5th, 2008
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
  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. ?>
It is NO SHAME to ask when you want to LEARN, but FOOLISH to behave knowledgeable when YOU DON'T.
Keep PEACE alive!
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 35
Reputation: Modo is an unknown quantity at this point 
Solved Threads: 0
Modo Modo is offline Offline
Light Poster

Re: need help with two simple php scripts

 
0
  #3
Nov 5th, 2008
i tried this already before it didnt work ..
i tried it now again like u said .. it didnt work either
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: need help with two simple php scripts

 
0
  #4
Nov 5th, 2008
is H a defined variable?
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 50
Reputation: jackakos is an unknown quantity at this point 
Solved Threads: 0
jackakos's Avatar
jackakos jackakos is offline Offline
Junior Poster in Training

Re: need help with two simple php scripts

 
0
  #5
Nov 5th, 2008
May be you need to wait for some of the Gurus to have a look.

Sorry it didn't work
It is NO SHAME to ask when you want to LEARN, but FOOLISH to behave knowledgeable when YOU DON'T.
Keep PEACE alive!
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 35
Reputation: Modo is an unknown quantity at this point 
Solved Threads: 0
Modo Modo is offline Offline
Light Poster

Re: need help with two simple php scripts

 
0
  #6
Nov 5th, 2008
it says on the website of php H is time
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: need help with two simple php scripts

 
0
  #7
Nov 5th, 2008
H is not a predefined variable by php that i know of.

try adding this to the top of the document:

  1. define('H',date("H"));
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 35
Reputation: Modo is an unknown quantity at this point 
Solved Threads: 0
Modo Modo is offline Offline
Light Poster

Re: need help with two simple php scripts

 
0
  #8
Nov 6th, 2008
thanks a lot .. this solved my first problem ..

do u have any tips for my second problem please?
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 23
Reputation: psycho007 is an unknown quantity at this point 
Solved Threads: 0
psycho007 psycho007 is offline Offline
Newbie Poster

Re: need help with two simple php scripts

 
0
  #9
Nov 6th, 2008
try the case statement, this would make things alot easier to code and to read.

Regards
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 35
Reputation: Modo is an unknown quantity at this point 
Solved Threads: 0
Modo Modo is offline Offline
Light Poster

Re: need help with two simple php scripts

 
0
  #10
Nov 6th, 2008
i solved the second problem at school
i think i deleted something by mistake ..
thanks guys ..
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC