retrodog Posted March 7, 2007 Share Posted March 7, 2007 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----------------------- <?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="[email protected]"> <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"> <span class="text">* (required)</span></td> </tr> <tr> <td class="form">E-mail:</td> <td><input class="form" type="text" name="email" size="20"> <span class="text">*</span></td> </tr> <tr> <td> </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"> <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-------------------------------- <?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; } } //set up the names of the database and table //$db_name ="brantley_NexusRecipients"; //$table_name ="Messages"; //connect to the server and select the database //$server = "localhost"; //$dbusername = "brantley_retrodo"; //$dbpassword = "enviro1"; //$connection = @mysql_connect($server, $dbusername, $dbpassword) or die(mysql_error()); //$db = @mysql_select_db($db_name,$connection)or die(mysql_error()); //$sql = "INSERT INTO $table_name VALUES //('','$_POST[name]', '$_POST')"; //$result = @mysql_query($sql,$connection) or die(mysql_error()); 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-------------------------------------- <?PHP $name = $_POST['name'] ; $email = $_POST['email'] ; $to = "[email protected]"; $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-ToE-Mail address blocked: See forum rules)"; $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!!"; ?> Link to comment https://forums.phpfreaks.com/topic/41647-help-with-a-contact-form/ Share on other sites More sharing options...
trq Posted March 7, 2007 Share Posted March 7, 2007 Are you getting any errors? What is actually happening and what is your expected results? Link to comment https://forums.phpfreaks.com/topic/41647-help-with-a-contact-form/#findComment-201802 Share on other sites More sharing options...
retrodog Posted March 7, 2007 Author Share Posted March 7, 2007 Its just not recognizing the PHP. it shows all of the PHP code when the form is submitted. It works okay on my server but is not at all on the other server... Works okay... www.brantley-janice.com/Anne/staging/jump-in.php --> validation are shown if you click submit without entering any data http://www.christchurchlife.com/staging/feedback2.php --> validation shows if you click Submit without entering any data, or if you enter all data and click Submit email functionality works as its supposed to Not working... http://www.christchurchlife.com/staging/jump-in.php --> no validation if you click Submit without entering any data http://www.christchurchlife.com/staging/feedback2.php --> no validation if you click Submit without entering any data, or if you enter all data and click Submit get the following error: PHP Fatal error: Call to undefined function checkdnsrr() in \\128.0.0.200\wwwroot\cpclife.org\staging\SendMail.php on line 60 Link to comment https://forums.phpfreaks.com/topic/41647-help-with-a-contact-form/#findComment-201812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.