psquillace Posted February 8, 2007 Share Posted February 8, 2007 Hello All, I am new to php and am trying to create a simple email script to send the following form at http://www.kem.com/contact-is.htmlto an email address. I am using someone elses script - mistake #1 - instead of writing it myself but I do not know what I am doing yet so I thought it would be better for me to just change the variables on this. When I go to the php page I made to check the form out all I get is a blank page I have the error script at the top of the php page and it is not commented out so I don't know why it wont tell me what I did wrong. The other thing is that I do not know how to just send to an email if a checkbox is checked. Here is what I did and someone tell me if I did this right or not. The whole thing is not posted due to length, I just want to make sure I got the right code $consumer_playing_cards = $_POST['consumer_playing_cards]; $professional_playing_cards = $_POST['professional_playing_cards']; $accessories = $_POST['accessories']; Then sending it to the email I have $recipient_email = 'paul@kardwell.com'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/plain; utf-8' . "\r\n"; $headers .= 'From: Feedback Form <paul@kardwell.com>' . "\r\n"; $headers .= 'Return-Path: paul@kardwell.com' . "\r\n"; $body = "A Message From Kem.com Website\r\n"; &body .= 'They Checked off:' .($consumer_playing_cards)"\r\n"; &body .= 'They Checked off:' .($professional_playing_cards)"\r\n"; &body .= 'They Checked off:' .($consumer_playing_cards)"\r\n"; mail ($recipient_email, 'Feedback from Kem.com Contact Page', $body, $headers); $message = 'Your message was successfully delivered!<br>Thank you for contacting Kem.com.'; } else { // If it did not run OK. $message .= 'Please try again!'; } Quote Link to comment Share on other sites More sharing options...
psquillace Posted February 9, 2007 Author Share Posted February 9, 2007 I found out that a blank page means there is an error in my php code but I do not know enough about php to find it. I looked and looked but do not find anything in there. Can another pair of eyes give a look and tell me if I am missing anything? <?php // As an added security measure, I've added the following line to .htaccess to fool spammers into thinking that a static html page is used // RewriteRule ^contact-us.html /contact.php // Error Checking. ini_set ('display_errors', 'On'); error_reporting (E_ALL); // Set relative path of page. if (dirname($_SERVER['PHP_SELF']) == '/') { $rel_path = ""; } else { $rel_path = "../"; } // Set valid domain host and http server values. Added all variations of valid domains in array $valid_hosts = array ('kem.com' , 'www.kem.com' , '204.15.120.147'); $errors = ''; $user_data = array(); $user_data['host'] = gethostbyaddr($_SERVER['REMOTE_ADDR']); $user_data['ip'] = $_SERVER['REMOTE_ADDR']; $user_data['agent']= $_SERVER['HTTP_USER_AGENT']; if (isset($_SERVER['HTTP_REFERER'])) { $user_data['ref'] = $_SERVER['HTTP_REFERER']; } else { $user_data['ref'] = ''; } $user_data['time'] = date("D M j G:i:s Y"); include ($rel_path . 'includes/email_validate.inc'); // Include custom email validation script if (isset($_POST['submit']) && ($_POST['submit'] == 'Submit')) { // Handle the form. $message = NULL; // Create a new empty variable. // Check for a First Name. if (empty($_POST['first_name']) || !valid_string($_POST['first_name'])) { $first_name = FALSE; $first_name .= 'Please Enter a First Name!<br>'; } else { $first_name = $_POST['first_name']; } // Check for a Last Name. if (empty($_POST['last_name']) || !valid_string($_POST['last_name'])) { $last_name = FALSE; $last_name .= 'Please Enter a Last Name!<br>'; } else { $last_name = $_POST['last_name']; } // Check for a Email. if (empty($_POST['email']) || !valid_string($_POST['email'])) { $email = FALSE; $email .= 'Please Enter a First Name!<br>'; } else { $email = $_POST['email']; } // Check for a Email Ok. if (empty($_POST['email_ok']) || !valid_string($_POST['email_ok'])) { $email_ok = FALSE; $email_ok .= 'Please verify your email.<br>'; } else { $email_ok = $_POST['email_ok']; } // Check for Area Code. if (empty($_POST['area_code']) || !valid_string($_POST['area_code'])) { $area_code = FALSE; $area_code .= 'Please describe your Overall Experience!<br>'; } else { $area_code = $_POST['area_code']; } // Check for Phone Number. if (empty($_POST['phone']) || !valid_string($_POST['phone'])) { $phone = FALSE; $phone .= 'Please Enter a Phone Number<br>'; } else { $phone = $_POST['phone']; } //Checkboxes - These do not need to be checked to continue $consumer_playing_cards = $_POST['consumer_playing_cards']; $professional_playing_cards = $_POST['professional_playing_cards']; $accessories = $_POST['accessories']; $other = $_POST['other']; // Check for Comments. if (empty($_POST['comments']) || !valid_string($_POST['comments'])) { $comments = FALSE; $comments .= 'Please Enter a message'; } else { $comments = $_POST['comments']; } if ( $first_name && $last_name && $email && $email_ok && $area_code && $phone && $comments && check_referer() ) { // If eveything is OK. // Send an email, if desired. $recipient_email = '***@****.com'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/plain; utf-8' . "\r\n"; $headers .= 'From: Feedback Form <***@****.com>' . "\r\n"; $headers .= 'Return-Path: ***@****.com' . "\r\n"; $body = "A Message From Kem.com Website\r\n"; $body .= 'Submit Date Time: ' . $user_data['time'] . "\r\n"; $body = 'The following feedback was submitted from ' . $_SERVER['HTTP_HOST'] . "\r\n\r\n"; &body .= 'First Name: ' . stripslashes(htmlspecialchars($first_name)) . "\r\n"; &body .= 'Last Name: ' . stripslashes(htmlspecialchars($last_name)) . "\r\n"; &body .= 'Email: ' . stripslashes(htmlspecialchars($email)) . "\r\n"; $body .= 'They Checked off:' .($consumer_playing_cards)."\r\n"; $body .= 'They Checked off:' .($professional_playing_cards)."\r\n"; $body .= 'They Checked off:' .($accessories)."\r\n"; $body .= 'They Checked off:' .($other)."\r\n"; $body .= 'Comments: ' . stripslashes(htmlspecialchars($comments)) . "\r\n"; $body .= 'Host: ' . $user_data['host'] . "\r\n"; $body .= 'IP: ' . $user_data['ip'] . "\r\n"; $body .= 'Remote Agent: ' . $user_data['agent'] . "\r\n"; $body .= 'Referrer: ' . $user_data['ref'] . "\r\n"; $body .= "Sincerely,\r\nKardwell International"; mail ($recipient_email, 'Feedback from Kem.com Contact Page', $body, $headers); $message = 'Your message was successfully delivered!<br>Thank you for contacting Kem.com.'; } else { // If it did not run OK. $message .= 'Please try again!'; } } // End of the main Submit conditional. ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 9, 2007 Share Posted February 9, 2007 Please use code tags, not quotes. Turn on error_reporting and you will see the error. If you don't have access to php.ini just add error_reporting(E_ALL); at the top of your script. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.