syngod Posted August 15, 2007 Share Posted August 15, 2007 Hey guys i am trying to get an html form to post to php to tell a story basically to test what i know but apparently......... it does not work the html is rather long now so i only posting a little. <html> <head> <title>Story</title> </head> <body> <h1>Story</h1> <h3>Please fill in the blanks below, and I'll tell you a story</h3> <form method = "post" action = "story.php"> <table border = 1> <tr> <th>Color:</th> <th> <input type = "text" name = "color" value = ""> </th> </tr> <tr> <th>Musical Instrument</th> <th> <input type = "text" name = "instrument" value = ""> </th> </tr> and the php is <?php print <<<HERE <h3> Little Boy $color, come blow your $instrument!<br> The $anim1's in the $place, the $anim2's in the $vegetable.<br> Where's the boy that looks after the $anim3?<br> He's under the $structure, $action. </h3> HERE; ?> Quote Link to comment https://forums.phpfreaks.com/topic/65150-solved-html-post-to-php/ Share on other sites More sharing options...
cooldude832 Posted August 15, 2007 Share Posted August 15, 2007 they are in the super global array $_POST so $_POST['color'] $_POST['name'] etcetc Quote Link to comment https://forums.phpfreaks.com/topic/65150-solved-html-post-to-php/#findComment-325237 Share on other sites More sharing options...
syngod Posted August 15, 2007 Author Share Posted August 15, 2007 global array $_POST so $_POST['color'] $_POST['name'] etcetc so i should place $_post before each variable Quote Link to comment https://forums.phpfreaks.com/topic/65150-solved-html-post-to-php/#findComment-325239 Share on other sites More sharing options...
trq Posted August 15, 2007 Share Posted August 15, 2007 None of the variables you use in story.php are defined anywhere. This is a result of the register_globals setting being off (a good thing) which has been the default in php for a long time now for security reasons. Use.... <?php print <<<HERE <h3> Little Boy {$_POST['color']}, come blow your {$_POST['instrument']}! The {$_POST['anim1']}'s in the {$_POST['place']}, the {$_POST['anim2']}'s in the {$_POST['vegetable']}. Where's the boy that looks after the {$_POST['anim3']}? He's under the {$_POST['structure']}, {$_POST['action']}. </h3> HERE; ?> instead. Quote Link to comment https://forums.phpfreaks.com/topic/65150-solved-html-post-to-php/#findComment-325240 Share on other sites More sharing options...
MadTechie Posted August 15, 2007 Share Posted August 15, 2007 in your html you have <tr> <th>Color:</th> <th> <input type = "text" name = "color" value = ""> </th> </tr> now the name = "color" is pulled into the php via $_POST['color'] not $color you could do $color = $_POST['color']; Quote Link to comment https://forums.phpfreaks.com/topic/65150-solved-html-post-to-php/#findComment-325241 Share on other sites More sharing options...
syngod Posted August 15, 2007 Author Share Posted August 15, 2007 awesome fixed and working great thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/65150-solved-html-post-to-php/#findComment-325247 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.