Hello
I am currently wanting to redesign some HTML forms which submit to a PHP mailer and improve some issues we currently have.
Our current methods has (for example) a form (form.html) that submits to the PHP mailer (go.php)
Inside the mailer, I have lines such as:
$_SESSION['supportname'] = htmlentities($_POST['NAME']);
and back on the HTML form:
<input type="text" name="NAME" class="formwidth" maxlength="32" value="<?php echo $_SESSION['supportname']; ?>" />
The problems we have:
1) None of our <select> menus are "protected" by this backup if some validation stops the submission going through... so it means the user has to reselect certain things
2) If the go.php is refreshed, it tries to insert data
So, to resolve this, I think the best method which I've seen elsewhere is where the form becomes a PHP script itself, say form.php and submits to itself
This also (I believe) means that when/if the form is refreshed, the HTML is sent rather than PHP trying to resubmit the data
My current PHP error function:
function send_error($msg) {
echo " <div class=\"white\">\n";
echo " <h1>Something went wrong ...</h1>\n\n";
echo " <p><img src=\"/img/offline.gif\" alt=\"Error\" /></p>\n\n";
echo " <p class=\"left\"><strong>Please correct the following:</strong></p>\n\n";
echo " <ul class=\"left\">\n".$msg."\n </ul>\n";
echo " </div>\n\n";
echo " <p class=\"righttext\"><small>Go back to <strong><a href=\"javascript:history.go(-1)\" title=\"previous page\">previous page</a></strong></small></p>\n\n";
exit();
}
What I'd really appreciate is any samples you guys have or use that work effectively in doing this. For the validation, it would be great if the HTML element (such as an input) could be changed to a red background where the error failed, or a select menu for the border to be red, along with errors along the top (such as that function above which works fine)
Thank you in advance