PHP and Forms!<

Hello,

I've managed to script a basic guestbook with PHP that writes entries to a file that are sent in through a form. I want to get a second button to preview the information, that will show the gathered information without writing it to file. My question is how do I get a second form button(written in orange in example) to call another webpage when someone clicks on it?

echo"
<form method=\"post\" action=\"$PHP_SELF?\"> \n


<p> Name:
<br /><input type=\"text\" name=\"name\" value=\"$name\" maxlength=\"$maxnamesize\" size=\"60\" />
<br />\nComments: <br /><textarea name=\"message\" cols=\"75\" rows=\"10\">$message</textarea><br>

<br /> \n <input type=\"submit\" value=\"Send it in! ;-]\" />\n <---this one calls $PHP_SELF?

<br /> \n <input type=\"submit\" value=\"Preview\" />\n <---How do I get this to read all the information the first one does and call a diferrent page? Ex: $PHP_SELF?func=Preview
</p>

</form>";

...
...
...

So that I could later do something like this...


if( $func == preview ) { // do preview code

} else { // write it to file

}well basically when you preview it is just getting the forms contents from post. so just get what they typed in more or less.


if( $func == preview ) { // do preview code
echo $_POST['name'];
echo "<br />";
echo $_POST['message'];
} else { // write it to file

}
 
Back
Top