Emailing HTML Form Data Using PHP Question

My code needs adjusting for my html form.

Page 1 of 1

2 Replies - 1253 Views - Last Post: 22 June 2009 - 04:11 PM Rate Topic: -----

#1 Ryanmiller  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 21-June 09

Emailing HTML Form Data Using PHP Question

Posted 22 June 2009 - 01:06 AM

I have an html form on a .tpl (Smarty enabled) file. The file is located in public_html/templates/celebration/ and here's the form's code:

{php}
if (!isset($_POST['submitForm'])) {
{/php}
Please fill out the form below regarding our advertising opportunities, and we'll get back to you within 24 hours. Thanks!
</td></tr></table><br /><br /><br />

<form method="post" action="advertise_form_send.php"> 
<table  width="70%" cellpadding="{$config.cellpadding}"  cellspacing="{$config.cellspacing}" border="0" align="center" style="text-align: center;">

<tr><td valign="top" width="30%">Name:<br /></td><td width="70%" valign="top"><input name="name" type="text"></td></tr>
<tr><td valign="top" width="30%">Company Name:<br /></td><td width="70%" valign="top"><input name="companyname" type="text"></td></tr>
<tr><td valign="top" width="30%">Email Address:<br /></td><td width="70%" valign="top"><input name="email" type="text"></td></tr>
<tr><td valign="top" width="30%">Message:<br /></td><td width="70%" valign="top"><textarea name="message" rows="15" cols="40"></textarea></td></tr>
<tr><td valign="top" width="30%"></td><td width="70%" valign="top"><input type="submit" name="Submit" alt="Submit"></td></tr>
</form>
{php}
} else {
echo "Form submitted!";
}
{/php}


Here is the form on my client's website: http://www.fullfigur...m/advertise.php

Now I do have some PHP code that I took from a site and modified accordingly, but it's not working. I don't get an error message, but I don't receive an email either.

Here's that PHP code on advertise_form_send.php:

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_POST['email'];
  $message = $_POST['message'];
  $name = $_POST['name'];
  $companyname = $_POST['companyname'];
  mail("ryanmiller406@gmail.com", "Advertisement Inquiry",
  $message, "From: $email", "Name: $name", "Company Name: $companyname");
  echo "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display error
  {
  echo "There was an error."
  }
?>

To be honest I don't even know if that code is close to being right. All I know is that it's simply not working.

Thanks in advance!

This post has been edited by Ryanmiller: 22 June 2009 - 01:10 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Emailing HTML Form Data Using PHP Question

#2 crazyjugglerdrummer  Icon User is offline

  • GAME OVER. NERD WINS.
  • member icon

Reputation: 119
  • View blog
  • Posts: 690
  • Joined: 07-January 09

Re: Emailing HTML Form Data Using PHP Question

Posted 22 June 2009 - 01:03 PM

look up usage of the mail function (and this is sort of a duplicate topic). it should only take 3 args.

mail("ryanmiller406@gmail.com", "Advertisement Inquiry",
$message . "From: $email" . "Name: $name" . "Company Name: $companyname");

You can just append them into one string (that will be the body of the messatge) instead of listing them as separate argunments
Was This Post Helpful? 0
  • +
  • -

#3 Ryanmiller  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 21-June 09

Re: Emailing HTML Form Data Using PHP Question

Posted 22 June 2009 - 04:11 PM

Thanks! It works perfectly!

Cool I just didn't understand that the mail function had a certain order to go in and that you have to group all of the message properties together.

Sweetness.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1