0

I tried using the example at http://www.w3schools.com/php/php_includes.asp

<a href="/default.php">Home</a>
<a href="/tutorials.php">Tutorials</a>
<a href="/references.php">References</a>
<a href="/examples.php">Examples</a>
<a href="/about.php">About Us</a>
<a href="/contact.php">Contact Us</a>
<html>
<body>

<div class="leftmenu">
<?php include("menu.php"); ?>
</div>

<h1>Welcome to my home page.</h1>
<p>Some text.</p>

</body>
</html>

I tried this:

<div id="topbar">
	<form method="post" action="parser.php">
		<p>URL: <input  type="text" name="url" size="80" /></p>
		<p><input type="submit" name="submit" value="View Feed" /></p>
	</form>
</div>
<div id="maincontent">
	<?php 
		if (isset($_POST['submit'])) {
			include 'parser.php';
		}
        ?>
</div>

And parser.php takes some input URL, parses it and outputs html but every time I click on submit, it takes me to another page instead of displaying the results in "maincontent". I can copy and paste the parser code and replace include 'parser.php' but is there a way to break it into separate files and make it work like the tutorial?

Basically I want the form to send values to another file and then have that file output the html back to the same form.

Thanks.

Edited by Makall: n/a

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by digital-ether
0

The form will be submitted to where the action parameter specifies.

eg:

<form method="post" action="parser.php">

will be submitted to parser.php

You can redirect to a different page using a HTTP redirect from that page after processing a form. Eg:

header("Location: /index.php");

will take you back to /index.php.

Edited by digital-ether: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.