Re: Calling file from a form
If you don't include the target property in the <form> tag, then it will open in the same window, not a new one.
And, all HTML tags require double quotes around property values. Your form tag is invalid.
Re: Calling file from a form
Thank you Peej!
Indeed without the target property it opens in the same window and i missed the quotes around the property values.
But what i'd like to do is to call guess.php from index.php but keep index.php displayed.
Yes i know that i can just include("index.php"); at the end of guess.php but is it the right way to do it?
Re: Calling file from a form
Don't include index.php at the end! Redirect back to the sender. As long as there's no output, it won't even seem like it was sent to a different for for processing.
PHP Code:
header ('Location: index.php');
Personally, it's better to have the current page do the form processing, that way, there isn't a redirect. Here's an example...
PHP Code:
<?php
if (isset($_POST['firstname'])) {
// posted data is detected...process the form data
}
?>
<form method="post" ... >
<input name="firstname" ... />
Re: Calling file from a form
The problem with redirection is that even if header() is at the end of the file, it wont process anything in the file before itself, it just redirects.
As far as to have the current page do the form processing i wanted to avoid to get the index.php file too big but if there is no other option i will process it there.
Re: Calling file from a form
Quote:
Originally Posted by
MasterDucky
As far as to have the current page do the form processing i wanted to avoid to get the index.php file too big but if there is no other option i will process it there.
If you really have an aversion to large files, you shouldn't be in the coding business. That's what happens...and it's one of the reasons why code commenting exists.
Second, just use an included file if you really have to have your code separate. Just include it right before the form.