Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 9th Sep 2010, 02:34 PM   #1
HyperActive Warrior
War Room Member
 
Colton's Avatar
 
Join Date: 2009
Location: Dallas, Texas
Posts: 201
Thanks: 63
Thanked 12 Times in 9 Posts
Default
How can I send my form in php with HTML?
Share on: 
fb share twitter share gplus share more share

Code:
if($_POST['name']!='' && $_POST['company']!='' && $_POST['e_mail']!='' && $_POST['telephone']!='' && $_POST['message']!='' && valid_email($_POST['e_mail'])==TRUE && strlen($_POST['message'])>15)
    {
        $to = 'email@yahoo.com';
        $headers =     'From: '.$_POST['e_mail'].''. "\r\n" .
                'Reply-To: '.$_POST['e_mail'].'' . "\r\n" .
                'X-Mailer: PHP/' . phpversion();
        
        
        $subject = "Message From website.com";
        $message = htmlspecialchars($_POST['message']); 
        $message .= 'Company Name:'.htmlspecialchars($_POST['company']); 
        $message .= 'Name:'.htmlspecialchars($_POST['name']);  
        $message .= 'Telephone Number:'.htmlspecialchars($_POST['telephone']); 
        
        if(mail($to, $subject, $message, $headers))
That's what I have so far, but when I send the email through the form it's all bunched together. I want it to be laid out nice and easy to read. How can I do that? Thanks.
Colton is offline  
Unread 9th Sep 2010, 03:01 PM   #2
Active Warrior
 
Join Date: 2010
Posts: 36
Thanks: 0
Thanked 1 Time in 1 Post
Default
Re: How can I send my form in php with HTML?
Share on: 
fb share twitter share gplus share more share

Try adding a few newline chars at the end of the message var like so

$message = htmlspecialchars($_POST['message'])."\n";
$message .= 'Company Name:'.htmlspecialchars($_POST['company'])."\n";
$message .= 'Name:'.htmlspecialchars($_POST['name'])."\n";
$message .= 'Telephone Number:'.htmlspecialchars($_POST['telephone'])."\n";

Last edited on 9th Sep 2010 at 03:05 PM. Reason: code
Oakleaf is offline  
Unread 9th Sep 2010, 03:02 PM   #3
HyperActive Warrior
War Room Member
 
CBSnooper's Avatar
 
Join Date: 2009
Location: Bradford, UK
Posts: 214
Thanks: 17
Thanked 31 Times in 26 Posts
Default
Re: How can I send my form in php with HTML?
Share on: 
fb share twitter share gplus share more share

I'd put a < br > between the ' and Company Name, Name and Telephone number. This will make those appear on a new line.


$message = htmlspecialchars($_POST['message']);
$message .= '<br>Company Name:'.htmlspecialchars($_POST['company']);
$message .= '<br>
Name:'.htmlspecialchars($_POST['name']);
$message .= '<br>
Telephone Number:'.htmlspecialchars($_POST['telephone']);
[/CODE]

CBSnooper is offline  
Unread 9th Sep 2010, 03:23 PM   #4
Web Developer
 
Join Date: 2010
Location: Wisconsin
Posts: 322
Thanks: 2
Thanked 80 Times in 74 Posts
Default
Re: How can I send my form in php with HTML?
Share on: 
fb share twitter share gplus share more share

HTML breaks will not work unless it is sent as HTML

$message = htmlspecialchars($_POST['message']) . "\r\n";
$message .= 'Company Name:'.htmlspecialchars($_POST['company']) . "\r\n" ;
$message .= 'Name:'.htmlspecialchars($_POST['name']) . "\r\n" ;
$message .= 'Telephone Number:'.htmlspecialchars($_POST['telephone']) . "\r\n" ;

phpbbxpert is offline  
Unread 9th Sep 2010, 04:01 PM   #5
Bert
 
dealbert.net's Avatar
 
Join Date: 2010
Location: Pasadena, CA
Posts: 29
Thanks: 0
Thanked 4 Times in 4 Posts
Default
Re: How can I send my form in php with HTML?
Share on: 
fb share twitter share gplus share more share

Try wufoo.com. It has free form generator, very nice ones too. The fee-based ones allows to create more than 10 fields in a form.

I'm not affiliate with wufoo.

Last edited on 15th Sep 2010 at 11:17 AM. Reason: typo
dealbert.net is offline  
Unread 10th Sep 2010, 08:17 AM   #6
HyperActive Warrior
War Room Member
 
Colton's Avatar
 
Join Date: 2009
Location: Dallas, Texas
Posts: 201
Thanks: 63
Thanked 12 Times in 9 Posts
Default
Re: How can I send my form in php with HTML?
Share on: 
fb share twitter share gplus share more share

Thanks for the help guys!
Colton is offline  
Closed Thread


Bookmarks

Tags
form, html, php, send


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 06:46 PM.