Well you can do this a couple different ways. The easiest would probably be to have the do_auth.php file echo out to the user that either the code already exists or that they didn't enter anything. Then instruct them to use their back button to re-enter.
You could get a little fancier and have the do_auth.php file redirect back to the form.html page, passing a variable back to it stating what the error was. For example:
if($chk_code == '') {
header("Location: http://127.0.0.1/code.html?failed=nocode[/url]");
exit;
}
Then later on instead of echoing out to the user that the data was entered, just do:
f ($num <> 0) {
header("Location: http://127.0.0.1/points/code.html?failed=duplicate[/url]");
(note, you don't need the [/url] in there...that is just the message forum putting that in there...)
Then you would need to change your code.html to code.php and in the middle (where you want the error message to come out) put something like:
<?php
$failed = $_REQUEST['failed'];
if ($failed == "nocode") {
echo "I'm sorry, you did not enter any code in.";
}
if (failed == "duplicate") {
echo "Im sorry, that cod eis already entered, please try again";
?>
In case you didn't know or not, you can embed that php right into the middle of your html page. As long as you file extention is php it will run the html code and the php code.
There is a trick with those header redirects though. There can not be any html, php echo or anything outputed to the screen before you do that redirect or it will give you an error.
You could get even fancier if you wanted to. This is how I usually do code like the one you have. I create one file called code.php which contains all of my form information. Then I have the form post to itself <form method="post" action="code.php>
Then what I do is put a hidden field in my form called "action" and make it equal to yes.
Then I embed all my php code inside the code.php file under one big if statement:
<?php
$action = $_POST['action'];
if ($action == "yes" {
do all my php
}
?>
Then you could just echo the errors out to the user and you don't have to re-direct them. It saves a little time not having to load one page with just php and then redirect them back to the same page.
And it looks a little more flawless to the end user as they don't get a blank screen...then wait...then go back...if you see what I mean.
Let me know if all that makes sense.