Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.