Jump to content

[SOLVED] how to insert email into database


gudfry

Recommended Posts

hi all;

 

        can anyone tell me where can i find a good example for this;

        i have this whole code

       

 

$name    = $_POST['name'];

$sender  = $_POST['e_mail'];

$phone  = $_POST['phone'];

$subject = $_POST['subject'];

$message = $_POST['message'];

$email = $_POST['email'];

 

// Insert data into hotelinfo table

$sql="INSERT INTO mailRecord(name, sender, phone, subject, fax, message)

VALUES('$name', '$sender', '$phone', '$subject', '$message')";

$result=mysql_query($sql);

 

mysql_close();

 

$to  = ''.$email.'' . ', '; // note the comma

$to .= '[email protected]';

 

$subject = "$subject";

$body    = "Guest message.\n\n $message\n\n";

mail ($to , $subject, $body, 'From: '.$sender.'');

?>

 

<script type="text/javascript">

      alert("Thank you for sending a message!")

      window.history.back(1);

</script>

 

 

I cant inseert the data into database. pleas hlp me

 

thank for advance

You might try reversing your single and double quotes in your sql statement:

 

$sql='INSERT INTO mailRecord(name, sender, phone, subject, fax, message)

     VALUES("$name", "$sender", "$phone", "$subject", "$message")';

 

and the table name and fields may be case sensitive.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.