theory816 Posted July 30, 2013 Share Posted July 30, 2013 Im running a simple forum post script and when I fill out the form in html and run the php script this is whats echoing out. Thank you, $name, for your posting:$posting "; ?> I dont know whats going on. Link to comment Share on other sites More sharing options...
HartleySan Posted July 30, 2013 Share Posted July 30, 2013 Is the file extension .php? Are you running the script through a (virtual) server? Please show us the full script if you're still having trouble. Thank you. Link to comment Share on other sites More sharing options...
theory816 Posted July 31, 2013 Author Share Posted July 31, 2013 Yes im running these through xampp. Html <!DOCTYPE html <html lang="en"> <head> <meta charset="utf-8"/> <title>Forum Posting</title> </head> <body> <div><p>Please complete this form to submit your posting:</p> <form action="handle_post.php" method="post"> <p>First Name: <input type="text" name="first_name" size="20" /></p> <p>Last Name: <input type="text" name="last_name" size="20" /></p> <p>Email Address: <input type="text" name="email" size="30" /></p> <p>Posting: <textarea name="posting" rows="9" cols="30"></textarea></p> <input type="submit" name="submit" value="Send My Posting" /> </form> </div> </body> </html> PHP <!DOCTYPE html <html lang="en"> <head> <meta charset="utf-8"/> <title>Forum Posting</title> </head> <body> <?php $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $posting = nl2br($_POST['posting']); $name = $first_name . ' ' . $last_name; print "<div>Thank you, $name, for your posting: <p>$posting</p></div>"; ?> </body> </html> Link to comment Share on other sites More sharing options...
HartleySan Posted July 31, 2013 Share Posted July 31, 2013 I just ran your scripts on my local XAMPP server exactly the way you wrote them above and they worked fine. Are you sure you started the Apache server from the XAMPP Control Panel? Link to comment Share on other sites More sharing options...
theory816 Posted July 31, 2013 Author Share Posted July 31, 2013 yes I made sure the apache server on xampp is on. Its still giving me that output. Link to comment Share on other sites More sharing options...
HartleySan Posted July 31, 2013 Share Posted July 31, 2013 What does your file structure in the htdocs folder for these two files look like? Also, what's the exact URL you're typing into the browser to run the script? Link to comment Share on other sites More sharing options...
theory816 Posted July 31, 2013 Author Share Posted July 31, 2013 Im not typing anything into the url. Im just clicking the html and it opens up a new browser window and I just fill it out there. This is whats in the url when I click the html file: file:///C:/xampp/htdocs/tuanphp/posting.html Uploaded with ImageShack.us Uploaded with ImageShack.us Link to comment Share on other sites More sharing options...
HartleySan Posted July 31, 2013 Share Posted July 31, 2013 That's very likely your problem. With Apache running from the XAMPP Control Panel, try loading the page from the following URL and see if it works: http://localhost/tuanphp/posting.html Link to comment Share on other sites More sharing options...
theory816 Posted July 31, 2013 Author Share Posted July 31, 2013 ahhh got it to work like that. Thanks for your guys help. Btw this is a little off topic, but I am new to php and am currently reading the "php for the web 4th addition" Im having alot of trouble trying to remember all the functions they are throwing at me in the first few chapters. Do you guys have any tips to learning php? Link to comment Share on other sites More sharing options...
HartleySan Posted July 31, 2013 Share Posted July 31, 2013 Glad you got it working. As for learning PHP, all I can recommend is play with the code a lot. That's really the only way to learn it well. Almost always, if you do a Google search for "PHP" and the name of a PHP function, the first hit you will get is an explanation of how the function works on php.net, the official PHP web reference. That site can be helpful for figuring out how functions work so you don't have to memorize everything. My best advice though is to think of a project or something that you really want to make with PHP, and then do it. You will learn a lot by just coding. It's hard at first, no doubt, but you'll get used to it. You can always come to these forums as well when you're stuck. 1 Link to comment Share on other sites More sharing options...
theory816 Posted July 31, 2013 Author Share Posted July 31, 2013 Thanks, and will do! Link to comment Share on other sites More sharing options...
Recommended Posts