Web Design Forum  
 
Go Back   Web Design Forum > Web and Graphic Design > Web Design

Reply
 
LinkBack Thread Tools Display Modes
Old 11-04-2010, 07:10 PM   #1
New Member
 
Join Date: Oct 2010
Location: US
Posts: 11
Default Contact Form

I've tried a lot of different stuff to try and get my contact form to send the name, phone, company, and message in a single email. However, all I can get is it to just send the message. I used smoovo's php code from another thread, and that's what I tried to modify to get it to work.

Here's that code
PHP Code:
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  
{
  
//send email
  
$email $_REQUEST['email'] ;
  
$subject $_REQUEST['subject'] ;
  
$message $_REQUEST['message'] ;
  
mail"someone@example.com""Subject: $subject",
  
$message"From: $email" );
  echo 
"Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  
{
  echo 
"<form method='post' action='mailform.php'>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>"
;
  }
?>
Now here's some of the stuff I've done to it to try and make it work for my needs.

PHP Code:
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  
{
  
//send email
  
$subject $_REQUEST['subject'] ;
  
$name $_REQUEST['name'] ;
  
$email $_REQUEST['email'] ;
  
$company $_REQUEST['company'] ;
  
$phone $_REQUEST['phone'] ;
  
$message $_REQUEST['message'] ;
  
$yes $_REQUEST['yes'] ;
  
$no $_REQUEST['no'] ;
  
$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Company: $company <br>
Phone: $phone <br>
Message: $message <br>
Yes: $yes <br>
No: $no <br>
EOD;

  
mail"wridenour87@gmail.com"$subject$body );
  
  }
else
//if "email" is not filled out, display the form
  
{
  echo 
"<form method='post' action='mailform.php'>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>"
;
  }
?>
What do I need to do to make it work?
VoltronFutura is offline   Reply With Quote


Old 11-04-2010, 11:48 PM   #2
Gold Member
 
Join Date: Nov 2009
Location: New York
Posts: 370
Default

Try adding some headers, some servers will only send if the header is formatted a certain way.

From Soovo:
mail( "someone@example.com", "Subject: $subject", $message, "From: $email" );

Yours:
mail( "wridenour87@gmail.com", $subject, $body );

I think adding a 'From' may solve it but it could be more involved. Are you getting any errors?

Read this:
http://php.net/manual/en/function.mail.php
__________________
Submit to my Website Gallery | NY Web Design
bcee is offline   Reply With Quote
Old 11-05-2010, 02:45 AM   #3
Gold Member
 
smoovo's Avatar
 
Join Date: Oct 2010
Posts: 388
Default

Quote:
Originally Posted by bcee View Post
Try adding some headers, some servers will only send if the header is formatted a certain way.
That's right. I posted the basic script (this script works and also yours), but there is more components to add.

For example:
1. Headers - Email configuration. (in your script you are using HTML, you should add HTML content type)
2. Email check - if the email entered is valid.

So as bcee mentioned, add headers to your mail() function. The shorter header should be "From: $email".

You can read more about "Headers" in the php.net website.

- Enjoy.
__________________
SMooVo - Web Design & Development
contact@smoovo.com
www.SMooVo.com

Last edited by smoovo; 11-05-2010 at 02:47 AM.
smoovo is offline   Reply With Quote
Old 11-09-2010, 05:19 PM   #4
New Member
 
Join Date: Oct 2010
Location: US
Posts: 11
Default

I've tried all these solutions, but the problem is that it won't send the email at all. If I use the simple form, it sends, but I need all the information to send. At one point, it was sending the body code in the subject line. It's becoming very frustrating.

This is what I've got right now.
PHP Code:
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  
{
  
//send email
  
$subject $_REQUEST['subject'] ;
  
$name $_REQUEST['name'] ;
  
$email $_REQUEST['email'] ;
  
$company $_REQUEST['company'] ;
  
$phone $_REQUEST['phone'] ;
  
$message $_REQUEST['message'] ;
  
$yes $_REQUEST['yes'] ;
  
$no $_REQUEST['no'] ;

$body = <<<EOD
<br><hr><br>
Name: $name <br>
Company: $company <br>
Phone: $phone <br>
Message: $message <br>
Yes: $yes <br>
No: $no <br>
EOD;

  
mail"wridenour87@gmail.com"$body"From: $email" );  }
else
//if "email" is not filled out, display the form
  
{
  echo 
"<form method='post' action='mailform.php'>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>"
;
  }
?>
VoltronFutura is offline   Reply With Quote
Reply

Tags
contact, form, php

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 08:21 PM.


Camera Forum - Computer Forum - Web Design Forum

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.