Jump to content


Contact form help


5 replies to this topic

#1 Zadine

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 12 November 2005 - 08:24 AM

i need help, i am trying to send mail thought here, it would not send and i am geting Fatal error, could some one help me plzz?

This is my forum
<p><form method="POST" action="send.php">
    Contact form 
    <table width="100%" border="0">
    <tr> 
      <td width="15%">Name: </td>
      <td width="79%" colspan="2"><input name="name" type="text"></td>
    </tr>
    <tr> 
      <td>Email: </td>
      <td colspan="2"><input name="email" type="text"></td>
    </tr>
    <tr> 
      <td>Subject:</font></td>
      <td colspan="4"><select name="subject" id="subject">
          <option>Report an Error</option>
          <option>gfhgfh</option>
          <option>Other</option>
        </select> </tr>
    <tr> 
      <td>Message: </td>
      <td colspan="2"><textarea name="message" cols="50" rows="5">Enter your comments here...</textarea></td>
    </tr>
    <tr> 
      <td colspan="3"><div align="center"> 
          <input type="submit" name="Submit" value="Submit">
          <input type="reset" name="Submit2" value="Reset">
        </div></td>
    </tr>
  </table>
</form>

This is My Code
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = $_POST['subject'];

$recipients = "zadine@gameanimehybrid.com";

$headers["From"] = $email;
$headers["To"] = "zadine@gameanimehybrid.com";
$headers["Subject"] = $subject;

$body = $message;

$sendit = $mail_object->send($recipients, $headers, $body);
if (!$sendit)
     {
     echo("Your email has failed plz try again");
     } else{
     echo("Thankyou we for your Email");
     }
?>


#2 saferwaters

    Jedi In Training

  • Members
  • PipPip
  • 390 posts

Posted 12 November 2005 - 09:04 AM

$sendit = $mail_object->send($recipients, $headers, $body);

I dunno whatdacrap that is, but as far as I know the syntax for sending mail in PHP is mail(), which includes the address and headers and such.

php.net

#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 12 November 2005 - 12:51 PM

"dat crap" is OOP (object oriented programming), and is technically valid. The only problem is, and i can only assume since zadine didn't specify what the problem was, that he never set the object.

In simple terms, he either needs to find the mail class that and set the object before making that call, or change the code to this (i suggest this):
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = $_POST['subject'];

$recipients = 'zadine@gameanimehybrid.com';

$header = 'To: '.$email."\r\n"
               .'From: '$name.' <'.$email.'>';

if (!mail($recipients, $subject, $message, $header)){
    echo("Your email has failed please try again");
}else{
    echo("Thank you we for your Email");
}
?>
With any luck, that should work.

#4 Stu

    Retired P2L Staff

  • Publishing Betazoids
  • PipPipPipPip
  • 1,761 posts
  • Gender:Male

Posted 12 November 2005 - 01:57 PM

rc69, on Nov 12 2005, 05:51 PM, said:

"dat crap" is OOP (object oriented programming), and is technically valid. The only problem is, and i can only assume since zadine didn't specify what the problem was, that he never set the object.

In simple terms, he either needs to find the mail class that and set the object before making that call, or change the code to this (i suggest this):
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = $_POST['subject'];

$recipients = 'zadine@gameanimehybrid.com';

$header = 'To: '.$email."\r\n"
               .'From: '$name.' <'.$email.'>';

if (!mail($recipients, $subject, $message, $header)){
    echo("Your email has failed please try again");
}else{
    echo("Thank you we for your Email");
}
?>
With any luck, that should work.
i dont know why but i felt an insane urge to correct your english there...

    echo("Thank you for your Email");

or

    echo("We thank you for your Email");


#5 Zadine

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 13 November 2005 - 03:44 PM

ty for your help, sorry i didn't explain properly


I don't understant what "\r\n" is doing?

$header = 'To: '.$email."\r\n"
              .'From: '$name.' <'.$email.'>';

it still dosen't work

#6 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 13 November 2005 - 08:13 PM

http://php.net/manual/en/ref.mail.php

I don't know what you mean by it still doesn't work. Is it still giving you a fatal error? If so, what error?
If it's simply not sending the e-mail, then that's something you need to discuss with your host.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users