I did get your email from the form2mail. Working on the format it gives us now.
This is what it gives us:
Address 1:
test
Address 2:
test
City:
test
Zip:
11223
Phone Number:
11223344
Message:
test
With the from and subject where it should be. But as you can see we moved the output from the boxes to a line under, we did this because we couldn't figure out how to add a space in php.
Address 1:4938 example drive
Address 2:example,CA
City:example
This hurt the eyes without the spacing in there. We found something online about /n being a space in php coding? But that didn't seem to work out.
<?php
function isempty( $postvar , $title , $required = 0 , $min=0 , $max=0)
{
global $error_message;
if ( $required == 1 )
{
if ( empty( $_POST["$postvar"] ) )
{
$error_message .= "$title is required<br />";
}
}
if ( isset( $_POST["$postvar"] ) )
{
if($min>0)
{
if(strlen($_POST["$postvar"])<$min)
$error_message .= "$title is shorter then $min characters<br />";
}
if($max>0)
{
if(strlen($_POST["$postvar"])>$max)
$error_message .= "$title is longer then $min characters<br />";
}
$remove=array("\r","\t","\n");
$_POST["$postvar"] = htmlspecialchars( str_replace($remove," ",$_POST["$postvar"] ));
}
}
function is_mail($var)
{
global $error_message;
if ( !empty( $_POST["$var"] ) )
if ( !ereg( "^[^0-9][A-z0-9_-]+[@][A-z0-9_-]+([.][A-z0-9_-]+)*[.][A-z]{2,4}$", $_POST["$var"] ) )
{
$error_message .= "You have to add a valid email address<br />";
}
}
/* Functions Ends*/
$error_message='';
/***
* isempty("POST VARIABLE NAME" ,
* "ERROR TITLE" ,
* REQUIRED? ,
* MIN LENGHT ,
* MAX LENGHT )
***/
isempty( "name", "Your Name", 1 , 2,50);
isempty( "address1", "Your Address 1", 0 , 0,0);
isempty( "address2", "Your Address 2", 0 , 0,0);
isempty( "city", "City", 1, 1,50);
isempty( "zip", "Your Zip", 0 , 0,5);
isempty( "email", "Your Email", 1 , 5,40);
is_mail("email");
isempty( "phone", "Your Phone Number", 0 , 0,15);
isempty( "subject", "Message Subject", 1 , 2,40);
isempty( "message", "Message", 1 , 2,40);
/* If there is no error, */
if ( empty( $error_message ) )
{
$message_body='';
$subject='';
/*$subject.= "". $_POST["name"] ; //Subject ++ */
$message_body.= "Address 1:"."\r\n"; //message_body set from: Your Address 1
$message_body.= $_POST["address1"] ."\r\n";
$message_body.= "Address 2:"."\r\n"; //message_body set from: Your Address 2
$message_body.= $_POST["address2"] ."\r\n";
$message_body.= "City:"."\r\n";
$message_body.= $_POST["city"] ."\r\n";
$message_body.= "Zip:"."\r\n"; //message_body set from: Your Zip
$message_body.= $_POST["zip"] ."\r\n";
ini_set( 'sendmail_from', $_POST["email"] );
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n";
$headers .= "From: " . $_POST["email"] . " <" . $_POST["email"] . ">\n"; //optional headerfields
$message_body.= "Phone Number:"."\r\n"; //message_body set from: Your Phone Number
$message_body.= $_POST["phone"] ."\r\n";
$subject.= $_POST["subject"] ; //Subject ++
$message_body.= "Message:"."\n"; //message_body set from: Message
$message_body.= $_POST["message"];
$to = "support@southernohit.com"; //specify to( support@southernohit.com)
if(!empty($_SESSION[$message_body]))
die("You have sent this email thank you!");
else
{
$mailer = mail( $to, $subject, $message_body , $headers );
if ( $mailer == true )
{
$_SESSION[$message_body]=1;
print ( "<br>Thank You.<br><br>Message has been sent.<br><br>" );
print '<br />The page automatically redirected in 5 seconds.<META HTTP-EQUIV=Refresh CONTENT="5; URL=index.html">';
}
else
print ( "Error while sending the mail" );
}
}
else
{
print " $error_message <br />";
/* Here you should save the POST variables into session variable, and use dynaamic form in php to re-load the previously inserted form values! */
print '<br />The page automatically redirected in 10 seconds to the contact form, please correct the missing/wrong information.<META HTTP-EQUIV=Refresh CONTENT="10; URL=contact.html">';
}
?>
This is the form2mail I got to work with our server. I dunno maybe postfix didnt like the first one? Or apache, my box, something it just wouldn't get the job done.
I would also like to change my error message. I don't really like redirecting when the make a mistake, id like to maybe just have some red text by the required boxes pop out when an error happens. Is that possible with PHP or would I need a javascript to pull that off?
I was also wanting it to not print in the email if the boxes are empty, say if they don't put a mailing address. I assume I would need another function for that?
Probably the wrong place to be asking these question. >.>