Jump to content


Photo

php Mail() function not working for me.. please help


  • Please log in to reply
9 replies to this topic

#1 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 24 October 2006 - 11:11 PM

Here's my script:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>GSmash Tournament registration</title>
</head>
<body>

<?php
// Check to make sure that the user isnt spamming people via the form:
function spamcheck($field){
   if(eregi("to:", $field) || eregi("cc:", $field) || eregi(";", $field)){
      return true;
   }

   else{
      return false;
   }
}

function checkType(){
   if($_POST['type1'] == true && $_POST['type2'] == false){
      $type = 1;
   }

   elseif($_POST['type1'] == false && $_POST['type2'] == true){
      $type = 2;
   }

   elseif($_POST['type1'] == false && $_POST['type2'] == false){
      echo "<font color='red'>ERROR: You must select a tournament type.</font>";
   }

   else{
      $type = 3;
   }

return $type;
}
//Make sure the form is filled out:
if(isset($_POST['email'])){
   //check if the email address is invalid
   $mailcheck = spamcheck($_POST['email']);

   if((bool)$mailcheck == true){
      echo "Sorry, the e-mail you have entered is invalid, please re-enter it.";
   }

   else{ 
      //send email if the e-mail is valid
      $email = $_POST['email']; 
      $subject = "Smash Entry For: " . $_POST['name'];
      $type = checkType();
      $message = $_POST['sname'] . ", " . $_POST['char'] . ", " . $type;
      mail("Linkmaster424@aol.com", "Subject: " . $subject, $message, "From: " . $email . "\r\n");
      echo "Thanks for your entry!  Your data will be sent to the tournament staff.";
   }
}
 
else{
?>
   <h1 align="center">Glenwood SSBM Tournament Form</h1>
   <hr />
   <br />
   <h3 align="center">Fill out the form and click the &quot;Send&quot; button.</h3>
   <form method="post" action="http://smash.neogamerz.com">
   Email: <input type="text" name="email" /><br />
   Name: <input type="text" name="name" /><br />
   Smash Name: <input type="text" name="sname" max=4 min=1 size=16><br />
   Character: <input type="text" name="char" /><br />
   Entry Type(select at least one):<br />
   One on One:<input type="checkbox" name="type1"><br />
   Teams:<input type="checkbox" name="type2"><br />
   <input type='submit' value='send' />
   </form>

   <p><em>Note: In order to join the tournament, you will be required to pay an entry fee
   of $5.00 upon entry. &nbsp;This is mandatory for both teams and singles,
   meaning that if you are on a team, you AND your partner will need to pay the entry fee,
   totalling ten dollars. &nbsp;The same goes if you were to enter in both tournaments, you
   would have to pay a fee of ten dollars(five for each tournament).</em></p>
   <br />

   <p><font size="2">&copy;2006 By Tristan Nolan.</font></p>

<?php
}
?>
</body>
</html>

I've got the script working, but it's not mailing me the form data when you press submit.

#2 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 25 October 2006 - 01:16 AM

why dont you try this:
else{ 
//send email if the e-mail is valid
      $email = $_POST['email']; 
      $name = $_POST['name]; 
      $char = $_POST['char'];
      $to = "Linkmaster424@aol.com";
      $subject = "Smash Entry For: $name";
      $type = checkType();
      $message = "$name, $char, $type";
      $headers = "From: $email";
      mail($to, $subject, $message, $headers);
      echo "Thanks for your entry!  Your data will be sent to the tournament staff.";
   }]
I think that should do it... sorry if its incorrect but i usually never get a chance to help people since im very new to this too lol.. but this is something that i have learned!

#3 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 25 October 2006 - 01:51 AM

getting an error now:
Parse error: syntax error, unexpected T_STRING, expecting ']' in /home/pc72/public_html/smash/Test.php on line 54



#4 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 25 October 2006 - 02:16 AM

sorry i made a mistake.. i forgot the '' on one of the variables.. try this and tell me if you get another error
else{
//send email if the e-mail is valid
      $email = $_POST['email'];
      $name = $_POST['name'];
      $char = $_POST['char'];
      $to = "Linkmaster424@aol.com";
      $subject = "Smash Entry For: $name";
      $type = checkType();
      $message = "$name, $char, $type";
      $headers = "From: $email";
      mail($to, $subject, $message, $headers);
      echo "Thanks for your entry!  Your data will be sent to the tournament staff.";
  }]

#5 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 25 October 2006 - 03:36 AM

Parse error: syntax error, unexpected ']' in /home/pc72/public_html/smash/Test.php on line 61

Same error, different line

#6 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 25 October 2006 - 11:04 AM

line 61 is the mail function right?
mail($to, $subject, $message, $headers);
try putting it like this.. thats weird
does the stuff in the () have to be enclosed by '' or "" or something?
if not then i dont know cause i have my mail functions without ()

#7 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 25 October 2006 - 08:48 PM

I'll try quotes, maybe that'll work

#8 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 25 October 2006 - 08:53 PM

you've got a ] at the end of the code, i took that out and the page loaded, still no mail though. lemme take out the quotes again and try

#9 Design

Design
  • Members
  • PipPipPip
  • Advanced Member
  • 45 posts
  • LocationThe Computer Chair

Posted 26 October 2006 - 02:55 AM

still not working... anyone?

#10 patk24

patk24
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 26 October 2006 - 08:25 PM

wat r u trying to do?? uplaod it to a host?? some hosts dont allow the mail() function (trust me if been looking for ever for one..)
but ill take a look at your script and compare to mine and reply




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users