Jump to content

Recommended Posts

Hi guys,

 

I have a form which is meant to post to my database as well send me an email.

 

It posts to the database very fine but it returns the following error:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\site\reportingfaults.php on line 58

 

An not sure what to do, I am 2month new to PHP. I would appreciate your help in solving the problem.

 

Thanks.

 

Here is the code and form:

 

<?php 
// Parse the form data
if(isset($_POST['fault'])) {

    $fault = mysql_real_escape_string($_POST['fault']);

$sql = mysql_query("INSERT INTO csj_fault(fault, username, fault_date) 
        VALUES('$fault','$manager', now())") or die (mysql_error());

    //!!!!!!!!!!!!!!!!!!!!!!!!!    Email me    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    $to = "mailto:kamal.musah@yahoo.com";
$from = "$manager";
    $subject = "$manager reported a system fault";
    //Begin HTML Email Message
    $message = "$fault";

$headers  = "From: $from\r\n";
    $headers .= "Content-type: text\r\n";

    mail($to, $subject, $message, $headers);


   exit();

 header("location: index.php"); 
     exit();
}
?>

 

Form

                <form action="reportingfaults.php" method="post" enctype="multipart/form-data">
                 <table width="90%" border="0" cellspacing="0" cellpadding="6">
                      <tr>
                        <td align="right">Fault Description</td>
                        <td><label>
                      
                         <textarea name="fault" id="fault" cols="42" rows="5"></textarea>
                        </label></td>
                      </tr>
                      
                            <tr>
                        <td> </td>
                        <td><label>
                          <input type="submit" name="button" id="button" value="Send" />
                        </label></td>
                      </tr>
                      </table>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.