survey form on website is only sending the comments not the rest of the fields t

I have to do a form in PHP and it seems to be working/sending to my email OK, but only the comments field is showing up, not any of the other fields on the form. I have tried everything I know with my limited PHP knowledge. Can someone help me please??? :-[

[php]<?php
define(‘IRONCLAD_CAPTCHA_APIKEY’,’ IRONCLAD-CAPTCHA-xxxxxxxxxxxx’);
require(‘ironclad_captcha_lib.php’);

$captcha_result = ironclad_captcha_check(
IRONCLAD_CAPTCHA_APIKEY,
$_POST[‘ironclad_captcha_vx’],
$_POST[‘ironclad_captcha_input1’],
$_POST[‘ironclad_captcha_input2’],
$_POST[‘ironclad_captcha_input3’]
);

/* Specify your SMTP Server, Port and Valid From Address */
ini_set(“SMTP”,“myserver”);
ini_set(“smtp_port”,“25”);
ini_set(“sendmail_from”,“myemail”);

/*
This first bit sets the email address that you want the form to be submitted to.
You will need to change this value to a valid email address that you can access.
*/
$webmaster_email = “myemail”;

/*
This bit sets the URLs of the supporting pages.
If you change the names of any of the pages, you will need to change the values here.
*/
$feedback_page = “feedback_form-WORKED.php”;
$error_page = “error_message.php”;
$thankyou_page = “thank_you.html”;

/*
This next bit loads the form field data into variables.
If you add a form field, you will need to add it here.
/
$email_address = $_REQUEST[‘email_address’] ;
$name = $_REQUEST[‘name’] ;
$comments = $_REQUEST[‘comments’] ;
$phone = $_REQUEST[‘phone’] ;
$satisfaction = $_REQUEST[‘satisfaction’] ;
$obtainappointment = $_REQUEST[‘obtainappointment’] ;
/

The following function checks for email injection.
Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
*/
function isInjected($str) {
$injections = array(’(\n+)’,
‘(\r+)’,
‘(\t+)’,
‘(%0A+)’,
‘(%0D+)’,
‘(%08+)’,
‘(%09+)’
);
$inject = join(’|’, $injections);
$inject = “/$inject/i”;
if(preg_match($inject,$str)) {
return true;
}
else {
return false;
}
}

// If the user tries to access this script directly, redirect them to the feedback form,
if (!isset($_REQUEST[‘email_address’])) {
header( “Location: $feedback_page” );
}

// If the form fields are empty, redirect to the error page.
elseif (empty($email_address) || empty($comments)) {
header( “Location: $error_page” );
}

// If email injection is detected, redirect to the error page.
elseif ( isInjected($email_address) ) {
header( “Location: $error_page” );
}

// If email injection is detected, redirect to the error page.
elseif (!$captcha_result) {
header( “Location: $error_page” );
}

// If we passed all previous tests, send the email then redirect to the thank you page.
else {
mail( “$webmaster_email”, “Feedback Form Results”,
$comments, “From: $email_address” );
header( “Location: $thankyou_page” );
}
?>[/php]

Because you are only sending $comments as the mail body

[php]mail( “$webmaster_email”, “Feedback Form Results”, $comments, “From: $email_address” );[/php]

If you wanted to add additional fields you could build a body variable for example:

[php]
$body = "email_address: " . $email_address . “\n”;
$body .= "name: " . $name . “\n”;
$body .= "comments: " . $comments;

mail( “$webmaster_email”, “Feedback Form Results”, $body, “From: $email_address” );
[/php]

Thanks. Unfortunately I know nothing about PHP and when I try to do that, just as you typed, I get an error sending the message (That I didnt fill something out). Is this code supposed to go somewhere in particular, or have other components to it?

Or, does it replace this???
[php]$email_address = $_REQUEST[‘email_address’] ;
$name = $_REQUEST[‘name’] ;
$comments = $_REQUEST[‘comments’] ;
$phone = $_REQUEST[‘phone’] ;
$satisfaction = $_REQUEST[‘satisfaction’] ;
$obtainappointment = $_REQUEST[‘obtainappointment’] ;[/php]

Thanks so much for your help :slight_smile:

You would put my code at the bottom, replacing the existing mail() function

[php]

<?php define('IRONCLAD_CAPTCHA_APIKEY',' IRONCLAD-CAPTCHA-xxxxxxxxxxxx'); require('ironclad_captcha_lib.php'); $captcha_result = ironclad_captcha_check( IRONCLAD_CAPTCHA_APIKEY, $_POST['ironclad_captcha_vx'], $_POST['ironclad_captcha_input1'], $_POST['ironclad_captcha_input2'], $_POST['ironclad_captcha_input3'] ); /* Specify your SMTP Server, Port and Valid From Address */ ini_set("SMTP","myserver"); ini_set("smtp_port","25"); ini_set("sendmail_from","myemail"); /* This first bit sets the email address that you want the form to be submitted to. You will need to change this value to a valid email address that you can access. */ $webmaster_email = "myemail"; /* This bit sets the URLs of the supporting pages. If you change the names of any of the pages, you will need to change the values here. */ $feedback_page = "feedback_form-WORKED.php"; $error_page = "error_message.php"; $thankyou_page = "thank_you.html"; /* This next bit loads the form field data into variables. If you add a form field, you will need to add it here. */ $email_address = $_REQUEST['email_address'] ; $name = $_REQUEST['name'] ; $comments = $_REQUEST['comments'] ; $phone = $_REQUEST['phone'] ; $satisfaction = $_REQUEST['satisfaction'] ; $obtainappointment = $_REQUEST['obtainappointment'] ; /* The following function checks for email injection. Specifically, it checks for carriage returns - typically used by spammers to inject a CC list. */ function isInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } // If the user tries to access this script directly, redirect them to the feedback form, if (!isset($_REQUEST['email_address'])) { header( "Location: $feedback_page" ); } // If the form fields are empty, redirect to the error page. elseif (empty($email_address) || empty($comments)) { header( "Location: $error_page" ); } // If email injection is detected, redirect to the error page. elseif ( isInjected($email_address) ) { header( "Location: $error_page" ); } // If email injection is detected, redirect to the error page. elseif (!$captcha_result) { header( "Location: $error_page" ); } // If we passed all previous tests, send the email then redirect to the thank you page. else { $body = "email_address: " . $email_address . "\n"; $body .= "name: " . $name . "\n"; $body .= "comments: " . $comments; mail( "$webmaster_email", "Feedback Form Results", $body, "From: $email_address" ); header( "Location: $thankyou_page" ); } ?>

[/php]

That worked! Thanks so much!!!

Sponsor our Newsletter | Privacy Policy | Terms of Service