boyyo Posted April 18, 2011 Share Posted April 18, 2011 i just started a book called head first php and mysql and i think the syntax in the book is wrong this is what i put: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Aliens Abducted Me - Report an Abduction</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <h2>Aliens Abducted Me - Report an Abduction</h2> <?php $when_it_happened = $_POST['whenithappened']; $how_long = $_POST['howlong']; $alien_description = $_POST['description']; $fang_spotted = $_POST['fangspotted']; $email = $_POST['email']; echo 'Thanks for submitting the form.<br />'; echo 'You were abducted ' . $when_it_happened; echo ' and were gone for ' . $how_long . '<br />'; echo 'Describe them: ' . $alien_description . '<br />'; echo 'Was Fang there? ' . $fang_spotted . '<br />'; echo 'Your email address is ' . $email; ?> </body> </html> I saved it as an html as the book says and this is what comes out: Aliens Abducted Me - Report an Abduction '; echo 'You were abducted ' . $when_it_happened; echo ' and were gone for ' . $how_long . ' '; echo 'Describe them: ' . $alien_description . ' '; echo 'Was Fang there? ' . $fang_spotted . ' '; echo 'Your email address is ' . $email; ?> Is there a reason that it is putting that?Isnt it supposed to put out a form?Help Please! Quote Link to comment https://forums.phpfreaks.com/topic/234006-i-need-help-with-my-php-codeplzz/ Share on other sites More sharing options...
dcro2 Posted April 18, 2011 Share Posted April 18, 2011 You have to save it as a .php file. And there's no form there, so there won't be a form. I think this is the page where the form is supposed to be submitted. Quote Link to comment https://forums.phpfreaks.com/topic/234006-i-need-help-with-my-php-codeplzz/#findComment-1202775 Share on other sites More sharing options...
Skewled Posted April 18, 2011 Share Posted April 18, 2011 I enjoyed that book! Poor fang. As for the book I went over every subject in the book and found no issues. You can also head over to their main website and download the code found in the book here: http://www.headfirstlabs.com/books/hfphp/ And dcro2 gave the correct answer you're missing the form, and everything after <?php up until ?> goes into a file with the extension .php Quote Link to comment https://forums.phpfreaks.com/topic/234006-i-need-help-with-my-php-codeplzz/#findComment-1202781 Share on other sites More sharing options...
boyyo Posted April 18, 2011 Author Share Posted April 18, 2011 Ohhh!! So that code at the beggining: <label for="firstname">First name:</label> <input type="text" id="firstname" name="firstname" /><br /> <label for="lastname">Last name:</label> <input type="text" id="lastname" name="lastname" /><br /> <label for="email">What is your email address?</label> <input type="text" id="email" name="email" /><br /> <label for="whenithappened">When did it happen?</label> <input type="text" id="whenithappened" name="whenithappened" /><br /> <label for="howlong">How long were you gone?</label> <input type="text" id="howlong" name="howlong" /><br /> <label for="howmany">How many did you see?</label> <input type="text" id="howmany" name="howmany" /><br /> <label for="aliendescription">Describe them:</label> <input type="text" id="aliendescription" name="aliendescription" size="32" /><br /> <label for="whattheydid">What did they do to you?</label> <input type="text" id="whattheydid" name="whattheydid" size="32" /><br /> <label for="fangspotted">Have you seen my dog Fang?</label> Yes <input id="fangspotted" name="fangspotted" type="radio" value="yes" /> No <input id="fangspotted" name="fangspotted" type="radio" value="no" /><br /> <img src="fang.jpg" width="100" height="175" alt="My abducted dog Fang." /><br /> <label for="other">Anything else you want to add?</label> <textarea id="other" name="other"></textarea><br /> <input type="submit" value="Report Abduction" name="submit" /> </form> is the form. I thought you had to delete that and input the code that it says on the book and that would be the form! Ohhh wow im so dumb haha thanks for the help! I really appreciate it! Quote Link to comment https://forums.phpfreaks.com/topic/234006-i-need-help-with-my-php-codeplzz/#findComment-1202855 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.