Jump to content

mjtweaver

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Everything posted by mjtweaver

  1. Bizzare its started working all by itself, easiest fix ever! Thanks guys..
  2. Well, for the moment a simple paragraph would suffice. I would like to know where I am going wrong, so I can learn why.
  3. I am going through the tutorial found at http://goo.gl/69MeY and in my ultimate wisdom have decided to see if I can create a form, which you input some text, and then in the php file that handles the form in puts that variable into a text document using the fwrite function, basically creating a file from the website containing whatever text you put in. There is no specific purpose to this idea, I am just trying to implement everything I have learnt so far. Form: http://pastebin.com/J62UHBeT PHP Handler: http://pastebin.com/FHuaKkxD I someone could point me in the right direction of what I am doing wrong it would be much appreciated Thanks in advance Michael
  4. Again, thank you very much for your help. Working perfect now
  5. I'm going through the tutorial found here: http://devzone.zend.com/node/view/id/626 I've tried adapting the code that you helped me with to include elseif statements. I can't see how my code differs from the tutorials apart from the fact I am still using && operators. The only code I have edited is on the form handler page. <html> <head></head> <body> <?php // Retrieve Information $day = $_POST['day']; $time = $_POST['time']; $country = $_POST['country']; // Conditional Statement if ($day == 'thursday' && $time == '0800' && $country == 'uk') { $meal = 'You have selected the ultimate arrangement.'; } elseif ($day == 'friday') && $time = '1000' && $country == 'usa') { $meal = 'Unlucky your American.'; } else {$meal == 'Muppet';} ?> <h2>Your selection...</h2> <?php echo $meal; ?> </body> </html> I think I have an exceptional talent for breaking pages.
  6. Thank you very much for your help, the form is working just like I wanted.
  7. Thanks for your quick reply! Sorry for being a NEWB - kinda new from coding things from scratch - I've been more a cut & paster, but trying to learn the right way. Below is the code, I have updated. It does produce the "bacon and eggs" statement when I get all the conditions right, but it doesn't produce the "sausages" statement I was looking for if you didn't produce the right conditions. baconandeggs.php <html> <head></head> <body> <form action="baconandeggsform.php" method="post"> <!-- Question One --> <p>Please choose what day it is:</p> <select name="day"> <option value="monday">Monday</option> <option value="tuesday">Tuesday</option> <option value="wednesday">Wednesday</option> <option value="thursday">Thursday</option> <option value="friday">Friday</option> <option value="saturday">Saturday</option> <option value="sunday">Sunday</option> </select> <br /> <!-- Question Two --> <p>Please enter the time:</p> <input type="time" name="time"> <br /> <!-- Question Three --> <p>Please choose what country you are from...</p> <select name="country"> <option value="uk">UK</option> <option value="usa">USA</option> <option value="europe">Europe</option> </select> <!-- Form Submit --> <input type="submit"> </form> </body> </html> baconandeggsform.php <html> <head></head> <body> <?php // Retrieve Information $day = $_POST['day']; $time = $_POST['time']; $country = $_POST['country']; // Conditional Statement if ($day == 'thursday') { if ($time == '0800') { if ($country == 'uk') {$meal = 'bacon and eggs';} else {$meal = 'sausages';} } } ?> <?php echo $meal; ?> </body> </html> Could someone point me in the right direction?
  8. Hi guys (again), thanks a lot for your previous help. I'm trying to learn about conditional statements and I've tried to create a form to produce a echo statement when all the conditions are met. Below is my code, it is in two files... baconandeggs.php <html> <head></head> <body> <form action="baconandeggsform.php" method="post"> <!-- Question One --> <p>Please choose what day it is:</p> <select name="$day"> <option value="monday">Monday</option> <option value="tuesday">Tuesday</option> <option value="wednesday">Wednesday</option> <option value="thursday">Thursday</option> <option value="friday">Friday</option> <option value="saturday">Saturday</option> <option value="sunday">Sunday</option> </select> <br /> <!-- Question Two --> <p>Please enter the time:</p> <input type="$time" name="time"> <br /> <!-- Question Three --> <p>Please choose what country you are from...</p> <select name="$country"> <option value="uk">UK</option> <option value="usa">USA</option> <option value="europe">Europe</option> </select> <!-- Form Submit --> <input type="submit"> </form> </body> </html> baconandeggsform.php <html> <head></head> <body> <?php if ($day == 'thursday') { if ($time == '0800') { if ($country == 'uk') {$meal = 'bacon and eggs';} else {$meal = 'sausages';} } } ?> <?php echo $meal; ?> </body> </html> Any ideas why it isn't working? I've probably done something really obvious, but I have been trying to figure it out for a few hours now and it's doing my head in!
  9. Thanks for your help guys, much appreciated.
  10. I am learning PHP using the book "Beginning PHP and MySQL 5 - From Novice to Professional", and I have come across a lesson in the book which I am stuck on. The lesson is on using the echo() statement. I've typed in the following code and saved it as a php file.... <?php $heavyweight = "Lennox Lewis"; $lightweight = "Floyd Mayweather"; echo &heavyweight, " and ", $lightweight, " are great fighters."; ?> My Apache and PHP is working fine as my other PHP files work properly. When I try and view the file it says... "The website encountered an error while retrieving http://localhost:8888/phpdocs/multiplestringsecho.php. It may be down for maintenance or configured incorrectly." and when I click on more information it says... "HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request." Any ideas? Have I done something wrong? Any help would be much appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.