I have been looking at several pages of sollutions but I am lost in the woods.
Obviously i am using a contactform on my website, I have found a working script written by Betty, and I have contacted this person for some support however that was 5 days ago and no answer yet.
the Html part of the contact form asks for:
name,
surname,
email address,
message,
phonenumber,
If any of these required fields are not or not correctly filled in the PHP script opens up a white pages filled with error messages.
Than the user has to arrow back to the form page and start from scratch, this is ot only anoying but painfull, if you just typed a message of 1000 words and you typed your phone number wrong you get to do it all again lol
further more there is no thank you except after submitting where it clears the form reloads the page and in the addressbar it states the name of the page/thankyou
I have tried to tweak a few things and messed it up badly, i ended up spamming my own e-mail with over 50 test messages I need help!
Since I can not upload the php script I have copied and past it here,
What I would like to have:
error messages in a windows popup without clearing the entire form
a thank you message in a windows popup and clear the form/reload the page
***** original php script ****
PHP Code:
<?php
#**********************************************
# Contact Formulier vanBetty
#**********************************************
if(isset($_POST['email'])) {
// Pas deze twee regels aan.
$email_to = "seccondbest@aol.com";
$email_subject = "Bericht van een bezoeker";
function died($error) {
// je foutbericht staat hier
echo "Het spijt ons, vanwege een fout is het formulier niet verzonden. ";
echo "Deze fout(en) tonen zich hieronder.<br /><br />";
echo $error."<br /><br />";
echo "Ga aub terug om de velden correct in te vullen.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('Het spijt ons, er is een probleem opgetredn bij het verzenden van het formulier.');
}
$first_name = $_POST['first_name']; // verplicht
$last_name = $_POST['last_name']; // verplicht
$email_from = $_POST['email']; // verplicht
$telephone = $_POST['telephone']; // niet verplicht
$comments = $_POST['comments']; // verplicht
$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'Het emailadres is niet geldig.<br />';
}
$string_exp = "^[a-z .'-]+$";
if(!eregi($string_exp,$first_name)) {
$error_message .= 'De voornaam is niet geldig.<br />';
}
if(!eregi($string_exp,$last_name)) {
$error_message .= 'De achternaam is niet geldig.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'Het bericht is niet geldig.<br />';
}
$string_exp = "^[0-9 .-]+$";
if(!eregi($string_exp,$telephone)) {
$error_message .= 'Het telefoonnummer is niet geldig.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Gegevens formulier.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Voornaam: ".clean_string($first_name)."\n";
$email_message .= "Achternaam: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Telefoon: ".clean_string($telephone)."\n";
$email_message .= "Bericht: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
header("Location:contact.htm?thankyou");
?>
<?
}
?>
<?PHP
//Then outside the processing script add
If (isset($_GET['thankyou'])){
echo "Thank you for your email!<br/><br/>";
}
?>
the last part of this script //Then outside the processing script add if (isset bla bla bla), was my latest attempt to get a thankyou page and dindt work either
I am at a lost here and realy any help is welcom but pease I am a beginner and learn by tweaking and seeing, i tryed reading and that didnt work
thanks for reading my post
Bookmarks