Email Form Help

Trying to get email form to function

Page 1 of 1

5 Replies - 677 Views - Last Post: 06 February 2010 - 02:26 PM Rate Topic: -----

#1 smoky  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-February 10

Email Form Help

Posted 05 February 2010 - 03:23 PM

Can someone please tell me what is missing to have this form send multiple items such as email, name, phone and best time back to me through the email. I only get the name field returned to me by email. If I ask for more than one item in the message it errors out.



<?php
function spamcheck($field)
  {
  //filter_var() sanitizes the e-mail
  //address using FILTER_SANITIZE_EMAIL
  $field=filter_var($field, FILTER_SANITIZE_EMAIL);

  //filter_var() validates the e-mail
  //address using FILTER_VALIDATE_EMAIL
  if(filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
  else
    {
    return FALSE;
    }
  }

if (isset($_REQUEST['email']))
  {//if "email" is filled out, proceed

  //check if the email address is invalid
  $mailcheck = spamcheck($_REQUEST['email']);
  if ($mailcheck==FALSE)
    {
    echo "Invalid input";

}
  else
    {//send email
    $name =$_REQUEST['name'] ;
    $email = $_REQUEST['email'] ;
    $phone =$_REQUEST['phone'];
    $besttime =$_REQUEST['besttime'];
    $subject = $_REQUEST['Someone is requesting more info'];
    [b]$message =$_REQUEST['name'];[/b]
    mail("smoky.muehlstein@gmail.com", "Subject: $subject",
    $message, "From: $email" );
    echo "Thank you for requesting further information.";
    }
  }
else
  {//if "email" is not filled out, display the form
  echo " <form action='index.php' method='post' style='width: 240px;'>
<tbody>

<tr><td colspan='2' style='height: 10px;'></td></tr>
<tr><td width='79'><span class='login_text'>Your Name:</span></td>
<td width='152'><input name='name' class='input' type='text'></td></tr>

<tr><td colspan='2' style='height: 5px;'></td></tr>
<tr><td class='login_text'>Your Email:</td>
<td><input name='email' size='15' class='input' type='text'></td></tr>

<tr><td colspan='2' style='height: 5px;'></td></tr>
<tr><td class='login_text'>Phone:</td>
<td><input name='phone' size='15' class='input' type='text'></td></tr>

<tr><td colspan='2' style='height: 5px;'></td></tr>
<tr><td class='login_text'>Best Time:</td>
<td><input name='besttime' size='15' class='input' type='text'></td></tr>

<tr><td colspan='2' style='height: 10px;'></td></tr>
<tr><td></td><td><input name='submit' value='' class='submit' type='submit'></td></tr>

<tr><td colspan='2' style='height: 5px;'></td></tr>
<tr><td colspan='2'>
<p class='note'>* We hate spam as much as YOU do. Submit your info with the peace of mind knowing that your
information will never be shared or sold.</p></td></tr>
</tbody></form>";


  }
?>





Is This A Good Question/Topic? 0
  • +

Replies To: Email Form Help

#2 kinged007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 35
  • Joined: 05-November 09

Re: Email Form Help

Posted 05 February 2010 - 04:37 PM

hey dood,

$subject = $_REQUEST['Someone is requesting more info'];


There is no request here. There is no input with that name. Looks like you trying to set the subject of a string to this, so take it out of the $_REQUEST call.
Change it to :
$subject = 'Someone is requesting more info';


That changes it to a string to be used later. $_REQUEST is used to catch information passed through a POST or a GET request. eg Forms.

[b]$message =$_REQUEST['name'];[/b]


WTF is this???
This is NOT php! Learn your syntax! Dont try and mix BBCode with PHP, it doesnt work! lol
Remove it completely, because you have already defined $_REQUEST['name'], so this is not needed.

Read the errors and try and fix it according to what they say. The error report will give you a line number, go to that line in your code and check your syntax and stuff.

I think you may be trying to jump into slightly more advanced stuff before you have learned the basics. Go back and learn your syntax!

oh, and for your variable $message.

try write something like this:
$message = " Name: $name , Email : $email , Phone : $phone, Best Time : $besttime ";


Was This Post Helpful? 0
  • +
  • -

#3 smoky  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-February 10

Re: Email Form Help

Posted 05 February 2010 - 08:14 PM

Thanks. You are so right I am in over my head. But i think i can figure it out now
sorry about the BB crap mixed in Habits to bold i guess

Later

Smoky
Was This Post Helpful? 0
  • +
  • -

#4 smoky  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-February 10

Re: Email Form Help

Posted 05 February 2010 - 08:21 PM

one more thing
this works and gives me one long string of data

$message = " Name: $name , Email : $email , Phone : $phone, Best Time : $besttime ";

what do i do to break this into each on a separate line such as

Name: John Doe
Email: any@any.com
Phone: 123-123-1234
Best Time: 10

Thanks in advance for all your great help.
Was This Post Helpful? 0
  • +
  • -

#5 cam888  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 64
  • Joined: 20-February 09

Re: Email Form Help

Posted 06 February 2010 - 03:20 AM

Add a <br /> after each comma, to put it onto a newline.
Was This Post Helpful? 1
  • +
  • -

#6 kinged007  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 35
  • Joined: 05-November 09

Re: Email Form Help

Posted 06 February 2010 - 02:26 PM

<br /> will make your email look ugly unless you sending emails in HTML format....which I suspect you wont be.
SO, use '/n' instead of '<br />'
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1