Page 1 of 1

Email Form PHP Coding

Posted: Mon Sep 20, 2010 4:14 pm
by ghi572000
Hi new here so not sure if in the right forum, however I am using a email form in php and want to find a way so when the error messages in the form open, they will open in a pop up rather than having hit the back button to go back to the form? Do I need to add some JS to make this happen or is it a matter of adding some additional code somewhere?

This is the code im using in Code for sendemail.php:

Code: Select all

<?php

$ip = $_POST['ip']; 
$httpref = $_POST['httpref']; 
$httpagent = $_POST['httpagent']; 
$visitor = $_POST['visitor']; 
$visitormail = $_POST['visitormail'];
$subject = $_POST['subject'];
$phone = $_POST['phone'];
$notes = $_POST['notes'];
$attn = $_POST['attn']; 

if (eregi('http:', $notes)) {
die ("Please enter your message before you try submitting the form. ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo "<h2>Go Back - Please enter a valid e-mail address.</h2>\n"; 
$badinput = "<h2>Email not Valid something is wrong with the address you enterd.</h2>\n";
echo $badinput;
die ("Go back! ! ");
}

if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Go Back and fill in all fields correctly before you try submitting the form.</h2>\n";
die ("go back and try again"); 
}

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ; 
$subject = "WEB SITE MAIL" ; 

$notes = stripcslashes($notes); 

$message = "$todayis [EST] \n
Subject: $subject \n 
From: $visitor ($visitormail)\n
Phone: $phone \n 
Message: $notes \n
IP Address: IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";


mail("admin@myemail.co.uk", $subject, $message, $from);

?>

Any help will be appreciated
Regards
Gary

Re: Email Form PHP Coding

Posted: Wed Sep 22, 2010 8:03 am
by TonsOfFun
I don't know about the pop-up, but the way I do forms is that I make them 'sticky'.
So when the user clicks submit, it displays the errors at the top, and creates a form that has their previous answers in the fields.

Re: Email Form PHP Coding

Posted: Wed Sep 22, 2010 9:53 am
by ghi572000
Tons of fun thanks for your input but do you have an example of your method and how you implement it in to your forms?
Regards
Gary