Hello friends,
Will you please tell me, how can i display contents of the form on the same page of that form?
Thanks to all!

Recommended Answers

All 2 Replies

Hello friends,
Will you please tell me, how can i display contents of the form on the same page of that form?
Thanks to all!

:?: not a clear question for me.
anyway, contents of a form may not display on the same page of that form if it has the " action = 'page2.php' " like this :

//on page1.php
<form method = 'post' action = 'page2.php'>
- sample contents -
</form>

you won't include the " action = 'page2.php' " if you want the contents of the form to be displayed just in the same page where you write the form like this :

//on page1.php
<form method = 'post'>
- sample contents -
</form>

please do correct me if i'm wrong in terms of understanding your concern. Ϋ

Do you want to post back to the current page?

<?php
if (!empty($_POST['submit'])) {

echo $_POST['box'];

} else {
?>

<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<input type="text" name="box" />
<input type="submit" value="Submit" name="submit" />
</form>

<?php
}
?>

If you want to post back to the same page, use the above method. If you want to continue displaying the form after the submit, remove the else statement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.