Some elements of a form now showing on received email

Hi guys, I have another little problem with a form. I cannot get a couple sets of Radio buttons to show results in the email received. The page is live although not linked to from anywhere yet. www.hospitality-managers.com/contact.html
The page I think may be the problem is the freecontactformprocess.php - I think there may be something between these two pages not talking properly. I get the following results below whereby the website address is being sent thru correctly on the Website Address, but also again on the "style of Property: and the “Time required”. Any suggestions would be appreciated.
Form details below.

Full Name: G***** S*****

Email: *****@*****.com

Telephone: ######556

Website: www.hospitality-managers.com

Style: www.hospitality-managers.com

Time Required: www.hospitality-managers.com

Message: Another test from form 

I don’t see anything obviously wrong in the html of the form, other than the extra spaces in the inputs of the second set of radios.
So the problem is most likely within the processor.

1 Like

Yes, would need to see the form processing code.

1 Like

Hi guys, That’s what I thought it would be somewhere within the process page. Code is as follows:

<?php

if(isset($_POST['Email_Address'])) {
	
	include 'freecontactformsettings.php';
	
	function died($error) {
		echo "Sorry, but there were error(s) found with the form you submitted. ";
		echo "These errors appear below.<br /><br />";
		echo $error."<br /><br />";
		echo "Please go back and fix these errors.<br /><br />";
		die();
	}
	
	if(!isset($_POST['Full_Name']) ||
		!isset($_POST['Email_Address']) ||
		!isset($_POST['Telephone_Number']) ||
		!isset($_POST['Website']) ||
		!isset($_POST['style']) ||
		!isset($_POST['radSize']) ||
		!isset($_POST['Your_Message']) || 
		!isset($_POST['AntiSpam'])		
		) {
		died('Sorry, there appears to be a problem with your form submission.');		
	}
	
	$full_name = $_POST['Full_Name']; // required
	$email_from = $_POST['Email_Address']; // required
	$telephone = $_POST['Telephone_Number']; // not required
	$website = $_POST['Website']; // not required
	$style = $_POST['style']; // not required
	$radio = $_POST['radSize']; // not required
	$comments = $_POST['Your_Message']; // required
	$antispam = $_POST['AntiSpam']; // required
	
	$error_message = "";
	
	$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(preg_match($email_exp,$email_from)==0) {
  	$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
  if(strlen($full_name) < 2) {
  	$error_message .= 'Your Name does not appear to be valid.<br />';
  }
  if(strlen($comments) < 2) {
  	$error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  
  if($antispam <> $antispam_answer) {
	$error_message .= 'The Anti-Spam answer you entered is not correct.<br />';
  }
  
  if(strlen($error_message) > 0) {
  	died($error_message);
  }
	$email_message = "Form details below.\r\n";
	
	function clean_string($string) {
	  $bad = array("content-type","bcc:","to:","cc:");
	  return str_replace($bad,"",$string);
	}
	
	$email_message .= "Full Name: ".clean_string($full_name)."\r\n";
	$email_message .= "Email: ".clean_string($email_from)."\r\n";
	$email_message .= "Telephone: ".clean_string($telephone)."\r\n";
	$email_message .= "Website: ".clean_string($website)."\r\n";
	$email_message .= "Style: ".clean_string($website)."\r\n";
	$email_message .= "Time Required: ".clean_string($website)."\r\n";
	$email_message .= "Message: ".clean_string($comments)."\r\n\r\n".base64_decode($base)."\r\n";
	
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
header("Location: $thankyou");
echo "<script>location.replace('$thankyou')</script>";
}
die(); 

Hasn’t copied over that well, but hopefully you can make head or tail of it.

Cheers,

Notice anything in here?

Getting the form variables:

$website = $_POST['Website']; // not required
$style = $_POST['style']; // not required
$radio = $_POST['radSize']; // not required

and then using them:

$email_message .= "Website: ".clean_string($website)."\r\n";
$email_message .= "Style: ".clean_string($website)."\r\n";
$email_message .= "Time Required: ".clean_string($website)."\r\n";
1 Like

Hi there, I couldn’t see any difference between the bottom 3 lines, however I copied & pasted them as you have written. I wasn’t sure if you meant to completely remove the upper 3 lines of code or not. I tried removing them, but I then get the rest of the form delivering ok, but without the enquirers web address. (Before we had the www address on all 3 areas, website, style and time)

Form details below.

Full Name: G***** S*****
Email: *****@*****.com
Telephone: ######556
Website:
Style:
Time Required:
Message: Test 

Hi guys,
Thanks for the help so far. Getting closer. I have put things back where they were as far as the upper 3 lines of code are concerned, but changed the last two lines of the lower code as follows:

$email_message .= "Style: ".clean_string($style)."\r\n";
$email_message .= "Time Required: ".clean_string($time_required)."\r\n";

and I now have the Style of property coming thru as follows:
Form details below.

Full Name: G***** S*****
Email: *****@*****.com
Telephone: ######556
Website: www.hospitality-managers.com
Style: Apartment
Time Required: 
Message: Test again 

So it looks like all we have to do now is try and get the “Time Required” to show something.

Further suggestions?
Cheers.

By the way, I have just tried changing the last line from

$time_required to $radSize to be consistent with upper lines of code thinking that may be the problem, but still no go.

$email_message .= "Time Required: ".clean_string($time_required)."\r\n";

	$email_message .= "Time Required: ".clean_string($radSize)."\r\n";
 

That’s exactly it - there was no difference between them, so they are putting the same information in to your email three times. They need to reflect the different values from the form.

Again, though, look carefully at this line of code:

$radio = $_POST['radSize']; // not required

What variable contains the value that you want to put into your email?

Hi there, Not 100% sure I know what you mean. I tried the following because I thought it should be time:

$email_message .= "Time Required: ".clean_string($time_required)."\r\n";
``` but it didn't work, then I looked back and thought maybe it should reflect the name of the radio buttons being $radSize but as I mentioned above, that didn't work either. 

When I changed the "Style" one to:  ```
$email_message .= "Style: ".clean_string($style)."\r\n";
``` then it worked, so I thought the "Time Required" should be the same, but no go.

Cheers,

OK, to ask the question another way. Where does your $radSize variable come from? Answer: nowhere at all, you never create a variable with that name. You have a form field called radSize, but you have to get the value from that form field (sent to your PHP in an array called $_POST) and put it into a variable. You have a line of code like this:

$radio = $_POST['radSize']; // not required

which gets the form field contents and assigns it to a variable. What is that variable called? (Note - PHP variables start with a $ dollar sign).

Working, thank you again. I have now uploaded it as the real form www.hospitality-managers.com/form.php and all looking good.

Thanks again, Cheers.

Hello again droopsnoot, I have found another problem. It all works perfectly from the desktop, also from an i-Pad which I have tested on both as per below results:
Form details below.

Full Name: *****
Email: *****
Telephone: *****
Website: *****
Style: Apartment
Time: 1 Month
Message: Test from desktop

Form details below.
Full Name: *****
Email: *****
Telephone: *****
Website: *****
Style: Motel
Time: 2 Weeks
Message: Test from ipad

However, the 1st lot of radio buttons won’t show on a Samsung phone and then it won’t send thru.

Both pages are live again, the /contact.html page along with the linked page from all pages the /form.php page.

Do you have any idea why this is now happening? I’m sure it worked yesterday.

Sorry, no idea. If it’s not drawing on the phone, that suggests it’s not a PHP issue, because that doesn’t come into it until you submit the form to the server, so you might be best opening a new topic in the HTML section.

Only thing that looks weird is the id for one of the options in the first radio button set, b&amp;b seems a strange id. Could you change that and see if it alters anything?

Got it to work. The b&amp;bwas short for Bed & Breakfast. In fact it may have been working before, but you had to look real hard to see the radio buttons. I cured it be creating a background behind the radio button and label. I also made one value “checked” so it is obvious to change if it is not correct. Appears to work perfectly everywhere now and is very obvious on the Samsung phone now.
Cheers.

I got that, I just wasn’t sure whether the & would cause problems in an id. Seems as if it does not. Glad it’s working now.

Yep, all good now. Thanks again.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.