senca99 Posted October 27, 2009 Share Posted October 27, 2009 hey everyone, I made a form with just a submit button and a textfield in a div and (what I want to do) ==> put the output in another div. I made an index.php page looking like this: <html> <link href="oefening.css" rel="stylesheet" type="text/css"> <body> <div id="wrapper"> <div id="links"> <form action="script.php" method="post"> Name: <input type="text" name="name"/> <input type="submit"/> </form> </div> <div id="rechts"> <? include("script.php"); ?> </div> </div> </body> </html> The problem is that it works as long as I let the output appear in the original div the form is in.But when I want to make it appear in the other div it just returns a whit screen with my output in the left top of the page.I gave the div's some background colours with css and aligned them and it looks the way it should until I hit the submit button.Then I get the white page with the output.I used the include command(code above). The script it refers to looks like this: <html> <body> <? echo $_POST['name']; ?> </body> </html> I probably just make a stupid beginners mistake :s greetzzz Quote Link to comment https://forums.phpfreaks.com/topic/179231-why-does-the-include-command-return-a-white-page-with-my-submit-data/ Share on other sites More sharing options...
MadTechie Posted October 27, 2009 Share Posted October 27, 2009 Okay, your form is posting its data to script.php, But script.php is also being called in index.php.. Now as you want the post to appear on the same page, theirs no need for script.php here an example <html> <link href="oefening.css" rel="stylesheet" type="text/css"> <body> <div id="wrapper"> <div id="links"> <form action="" method="post"> Name: <input type="text" name="name"/> <input type="submit"/> </form> </div> <div id="rechts"> <?php echo $_POST['name']; ?> </div> </div> </body> </html> Note the post action is "" this mean post to self, now to expand on this, change <?php echo $_POST['name']; ?> to <?php if(isset($_POST['name'])) echo $_POST['name']; ?> as your get a notice saying $_POST['name'] was not set on the page prior to submitting Quote Link to comment https://forums.phpfreaks.com/topic/179231-why-does-the-include-command-return-a-white-page-with-my-submit-data/#findComment-945622 Share on other sites More sharing options...
bob2588 Posted October 27, 2009 Share Posted October 27, 2009 yea that will work Quote Link to comment https://forums.phpfreaks.com/topic/179231-why-does-the-include-command-return-a-white-page-with-my-submit-data/#findComment-945631 Share on other sites More sharing options...
senca99 Posted October 27, 2009 Author Share Posted October 27, 2009 the big question is,what did I do wrong so that the script doesn't work in the div "rechts" ? Because I made this work @ school last week with a php script attached to the index.php.Its supposed to work with a script because thats the whole clue of my lessons the next couple of months Quote Link to comment https://forums.phpfreaks.com/topic/179231-why-does-the-include-command-return-a-white-page-with-my-submit-data/#findComment-945679 Share on other sites More sharing options...
MadTechie Posted October 27, 2009 Share Posted October 27, 2009 you posted to script.php and that is basically a blank page, that echo's the post'ed data, so at best your get a blank page with some text, as script.php has no div's or anything else. Quote Link to comment https://forums.phpfreaks.com/topic/179231-why-does-the-include-command-return-a-white-page-with-my-submit-data/#findComment-945779 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.