Jump to content

why does the "include" command return a white page with my submit data?


senca99

Recommended Posts

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

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

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 :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.