Need help with feedback form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
KevinCB
Forum Commoner
Posts: 32
Joined: Tue Mar 01, 2005 6:00 am

Need help with feedback form

Post by KevinCB »

Hi

I've created a feedback form which sends an e-mail containing the data entered into the form, and would like to know if I can change the way that the contents of the form are inserted into an e-mail.

Here's part of the e-mail generated by the php:
Users name: Kevin B
Business Name: Test
Address: 56 Milton Road
Crewe
Cheshire

Postcode: CW2 6FG
Telephone No: 01270 586790
Is it possible to get the address part to have the next line underneath the other so that they are inline?

Here's the php script I'm using:

Code: Select all

<?php if (isset($_POST['submit_form'])) // if the form was sent do the following
{ 
	$name = $_POST['name'];
	$busname = $_POST['busname'];
	$addr = $_POST['addr'];
	$postcode = $_POST['postcode'];
	$tel = $_POST['tel'];
	$email = $_POST['email'];
	$nature = $_POST['nature'];
	$msg = $_POST['msg'];
	$about = $_POST['about'];
	
	$headers = 'From: '.$name.' <'.$email.'>' . "\r\n" .
			'Reply-To: '.$email.'' . "\r\n" .
			'X-Mailer: PHP/' . phpversion();
		
	$message = 'Name: '.$name."\n"
			   .'Business Name: '.$busname. "\n"
			   .'Address: '.$addr. "\n\n"
			   .'Postcode: '.$postcode. "\n"
			   .'Telephone No: '.$tel. "\n"
			   .'E-mail Address: '.$email. "\n\n"
			   .'Feedback Comments: '.$msg. "\n";

	mail("you@yourmailaddress.com","::: Feedback :::","$message","$headers") or die("email error");
	echo '<br />Thank you for your message!'; // if all went well, display message was sent

} // end php submission code ?>
Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the line with Address in it, remove the second \n
KevinCB
Forum Commoner
Posts: 32
Joined: Tue Mar 01, 2005 6:00 am

Post by KevinCB »

That's not really what I wanted, let me explain it a little better.

The following is how it comes out:
Users name: Kevin B
Business Name: Test
Address: 56 Milton Road
Crewe
Cheshire

Postcode: CW2 6FG
Telephone No: 01270 586790
But I would like it inline as follows (the x's represent spaces, I had to put them in to space it across):
Users name: Kevin B
Business Name: Test
Address: 56 Milton Road
xxxxxxxxCrewe
xxxxxxxxCheshire

Postcode: CW2 6FG
Telephone No: 01270 586790
Is this possible?
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

CSS would be the best way.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Why don't you just do this...

Code: Select all

Address:
Whatever
Whatever
Whatever
If you want the address lines lined up.
I don't really understand why you would need that in an email... but oh well.
If you want to, you can set the mail headers to send in html format, so you can just format the email like a web page. That would work too.
Post Reply