DGray16 Posted September 6, 2013 Share Posted September 6, 2013 I'm having to create a simple madlib game in php but whenever I open the html document but whenever I submit it on the html site it doesn't print it right. html code <html><body><h1> My MadLib Lab </h1><form action="madlib.php" method="REQUEST">Enter a Noun: <input type="text" name="noun1" ><br />Enter an Adjective: <input type="text" name="adj1" ><br /><input type="submit" value="Click to see your MadLib" ></form></body></html> php code <html><body><?php$noun1 = $_REQUEST['noun1'];$adj1 = $_REQUEST['adj1'];print <h1>"The $adj1 old $noun1"</h1>;print <br>"There once was an $adj1 $noun1, who lived in a van down by the river."</br>;print <br>"<The end."</br>;?></html>s ou</body> This is what it prints out "The $adj1 old $noun1"; There once was an $adj1 $noun1, who lived in a van down by the river.; print "The end."; ?> Any help would be appreciated. Thanks, David Quote Link to comment https://forums.phpfreaks.com/topic/281907-simple-madlib-help/ Share on other sites More sharing options...
Psycho Posted September 6, 2013 Share Posted September 6, 2013 Are you running these pages on a web server or are you opening them up directly on your PC? PHP files must be requested from a web server that has PHP enabled so it can execute the PHP code and send the output to the browser. You can set up a webserver on your machine if you want using something like XAMPP or WAMP. but, I bet if you look at the source code of the page you will see that ALL of the code from madlib.php is there. You just can't see the PHP code in the display because the HTML considers the PHP opening/closing tags as HTML tags and hides it. Quote Link to comment https://forums.phpfreaks.com/topic/281907-simple-madlib-help/#findComment-1448406 Share on other sites More sharing options...
DGray16 Posted September 6, 2013 Author Share Posted September 6, 2013 I'm opening it with firefox straight from my PC. I'm running XAMPP with Apache and MySQL running. Quote Link to comment https://forums.phpfreaks.com/topic/281907-simple-madlib-help/#findComment-1448407 Share on other sites More sharing options...
kicken Posted September 6, 2013 Share Posted September 6, 2013 You need to access them via apache using a URL, not by just opening them directly in the browser (with file->open for example). Open your browser then go to the URL http://localhost/madlib.php and it should work, assuming you have saved your madlib.php file into the document root folder that xampp sets up. Quote Link to comment https://forums.phpfreaks.com/topic/281907-simple-madlib-help/#findComment-1448408 Share on other sites More sharing options...
DGray16 Posted September 6, 2013 Author Share Posted September 6, 2013 Which folder under xampp should I save the madlib.php in? Quote Link to comment https://forums.phpfreaks.com/topic/281907-simple-madlib-help/#findComment-1448410 Share on other sites More sharing options...
DGray16 Posted September 6, 2013 Author Share Posted September 6, 2013 I have it saved under htdocs and when I try opening it up through local host or even the xampp server it's still not working. Quote Link to comment https://forums.phpfreaks.com/topic/281907-simple-madlib-help/#findComment-1448411 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.