Page 1 of 1

need help with contact form

Posted: Wed Mar 07, 2007 7:44 am
by retrodog
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have three pages that are recognizing the PHP on a server running 4.3.11 but not on a server running 5.2.1.  I know there were some changes between the 2 but I can't figure out what I need to change.  The hosting provider of the latter indicated that it was not a confguration setting.  I've posted the code for my three pages below.  Anything you can do to help would be appreciate...Also, when there is an error with one of the fields on my page, the info already entered by the user gets lost...and the field is blank again.  How do I get the values to be retained???  the three pages below are for a basic contact form for which info is then emailed to the recipient as a confirmation and the admin.  Please help...THANKS!

------------page #1

Code: Select all

<?PHP 
$name = $_POST['name'] ;
$email = $_POST['email'] ;

 if($_GET['msg'] == "error") { 
$msg = "Please complete all required fields.";
$font = "<font color=red>";
 }
  elseif($_GET['msg'] == "email") { 
$msg = "Please provide a valid email address.";
$font = "<font color=red>";
 }
 elseif($_GET['msg'] == "success") { 
 $msg = "Thank you.  Your message has been sent.";
 }
 else {
 $msg='';
 $font='';
 }
?>
					
<li><strong>If you want more info or are ready to JUMP IN! give us your contact info:</strong></li>
					
<form method="post" action="SendMail_Nexus.php">                                                         
<input type="hidden" name="email" value="ecopeland@christchurchlife.com">
<input type="hidden" name="subject" value="I'm interested in learning more about Christ Church Fellowship">
<input type="hidden" name="required" value="name, email">
<table cellpadding="1" cellspacing="0" align="center">
<tr><td colspan=2><b><?PHP=$font?><?PHP=$msg?></b></td></tr>
<tr>
<td class="form">Name:</td>
<td><input class="form" type="text" name="name" size="20">&nbsp;<span class="text">* (required)</span></td>
</tr>
<tr>
<td class="form">E-mail:</td>
<td><input class="form" type="text" name="email" size="20">&nbsp;<span class="text">*</span></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="right" class="form"><input style="border-color:#413500; border-width:thin; border-style:dotted; padding:1;" class="form" type="submit" value="Submit" name="submit">&nbsp;<input style="border-color:#413500; border-width:thin; border-style:dotted; padding:1;" class="form" type="reset" value="Clear" name="reset"></td>
</tr>
</table>
</form>
------------page #2

Code: Select all

<?PHP

$name = $_POST['name'] ;
$email = $_POST['email'] ;

if ($_POST['email'] == "" || $_POST['name'] == "")  {
 header("Location: jump-in.php?msg=error");
exit;
}

if($email != ""){
if( !emaila($_POST['email']) ){ 
 header("Location: jump-in.php?msg=email");
exit;
} 
}
\
      include "globals_Nexus.php";

	 $email_body .= "Please contact me at the email address below. Thank you!"."\n\n";
	  $email_body .= "Name: $name"."\n";
	   $email_body .= "Email Address: $email"."\n";

	  
//		  print $email_body; exit;
		  
	if( mail($to,$subject,stripslashes($email_body),$mailheaders))  {
	     //mail($cc,$subject,$email_body,"Reply-To: $email\r\n"); 
	    mail($email,$auto_subject,$auto_message,$mailheaders1); 
	   header("Location: jump-in.php?msg=success"); 
	exit;
	}
	 else {
	  header("Location: jump-in.php?msg=issue");
	   exit;
	 }
	 
   
  function emaila($email){  
	if (!eregi("^[0-9a-z_]([-_.]?[0-9a-z])*@[0-9a-z][-.0-9a-z]*\\.[a-z]{2,4}[.]?$",$email, $check)){
		return false;
	}
	$host = substr(strstr($check[0], '@'), 1);
	if (!checkdnsrr($host.'.',"MX")){
		return false;
	}
	return true;
}   

?>
---------Page 3

Code: Select all

<?PHP

$name = $_POST['name'] ;
$email = $_POST['email'] ;

$to = "retrodog@comcast.net";
	$mailheaders1  = "MIME-Version: 1.0\r\n";
	$mailheaders1 .= "Content-type: text/plain; charset=iso-8859-1\r\n";
	$mailheaders1 .= "From: Christ Church\n";
	$mailheaders1 .= "Reply-To: ecopeland@christchurch.com"; 

	$mailheaders  = "MIME-Version: 1.0\r\n";
	$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
	$mailheaders .= "From: $name \n";
	$mailheaders .= "Reply-To: $email"; 
	
$auto_subject = "Thank you for your interest in Christ Church";

$auto_message = "As a member of Christ Church Fellowship, you will receive our regular email newsletter, Nexus, containing all the church news and updates. We will be contacting you shortly with more information. Thanks for your interest!!";
?>
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Mar 11, 2007 2:30 pm
by kendall
Well for one thing you have a hidden field named 'email' and an input field named 'email'

mite want to sort that out

secondly

when you get an error you are redirecting back to the form. so the POST variables wont be carried back...

thirdly try

Code: Select all

<input name="email" type="text" value="<?php echo $_POST['email']; ?>" />