need a little help with PHP mail

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
elitefreke
Forum Newbie
Posts: 3
Joined: Wed Sep 10, 2003 2:26 am

need a little help with PHP mail

Post by elitefreke »

Greetings. I am kinda new to the PHP lanquage and I just wrote a script for my site where users may submit a form via email. It seems to work when "Submit" is pressed, but I am not recieving the email! Please help!

the form link is: http://www.midnightracing.org/joinapp.html

the script for the php file is:

Code: Select all

<?php
  //create short variable names
  $name=$_POST&#1111;'name'];
  $location=$_POST&#1111;'location'];
  $email=$_POST&#1111;'email'];
  $age=$_POST&#1111;'age'];
  $sex=$_POST&#1111;'sex'];
  $year=$_POST&#1111;'year'];
  $make=$_POST&#1111;'make'];
  $model=$_POST&#1111;'model'];
  $currentmods=$_POST&#1111;'currentmods'];
  $futuremods=$_POST&#1111;'futuremods'];

  $toaddress = 'webmaster@midnightracing.org';
  $subject = 'New Membership Request';
  $mailcontent = 'Name: '.$name."\n"
                 .'Age: '.$age."\n"
                 .'Email: '.$email."\n"
                 .'Sex: '.$sex."\n"
                 ."Vehicle Info: \n"
                 .'Year: '.$year."\n"
                 .'Make: '.$make."\n"
                 .'Model: '.$model."\n"
                 .'Current Mods: '.$currentmods."\n"
                 .'Future Mods: '.$futuremods."\n";
  $fromaddress = 'From: webserver@example.com';

  mail ($totaladdress, $mailcontent, $fromaddress);
?>
<html>
<head>
  <title>Feedback Submitted</title>
</head>
<body>
<center>
<h1>Feedback Submitted</h1>
<p>Your info has been sent!</p>
</center>
</body>
</html>
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

shouldn't this line

Code: Select all

mail ($totaladdress, $mailcontent, $fromaddress);
be

Code: Select all

mail ($toaddress, $mailcontent, $fromaddress);
Mark
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

no. mail must have a (set of) to address(es)
then a subject
then the content


optional is other headers, such as a from address.

you have no subject, so your to addresses are getting an e-mail of a truncated message and your from address


so it should be mail($toaddress, $subject, $content, $from);
Last edited by m3rajk on Wed Sep 10, 2003 8:20 pm, edited 1 time in total.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

He means:
You are using these two lines in your script:

Code: Select all

$toaddress = 'webmaster@midnightracing.org';
// ...
mail ($totaladdress, $mailcontent, $fromaddress);
Are you seeing the difference?
elitefreke
Forum Newbie
Posts: 3
Joined: Wed Sep 10, 2003 2:26 am

Post by elitefreke »

yep... i see what i did. thanks for the help!
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

JAM wrote:He means:
You are using these two lines in your script:

Code: Select all

$toaddress = 'webmaster@midnightracing.org';
// ...
mail ($totaladdress, $mailcontent, $fromaddress);
Are you seeing the difference?
thanx. i got sidetracked with my mother's complaining about something as i wrote that.
Post Reply