如何使用数据库将这些值发送到邮件

时间:2018-01-29 04:35:17

标签: php

我是php新手。无法将这些值发送到邮件。我想将此表单值发送到邮件和我的数据库。可能有2封邮件吗?我在我的网站上使用此表单作为弹出窗口,可以在表单代码中将值发送到数据库。

<?php
$servername = 'localhost';
$username = '********';
$password = '*****';
$dbname = '********';

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
if (isset($_REQUEST['mailsend']))
{
    $firstname  = $_POST['FirstName'];
    $email      = $_POST['email'];
    $number     = $_POST['number'];
    $query      = $_POST['query'];
    $subject = "A New Query";
    $message = "Name:" .$firstname. "\r\n";
    $message .=" Email:" .$email.  "\r\n" ; 
    $message .= "Mobile Number:" .$number. "\r\n"; 
    $message .= "Query:" .$query. "\r\n"; 
    print_r($message);
    $sql = "INSERT INTO query (name,email,phone,query) VALUES ('$firstname', '$email', '$number', '$query')";

    if ($conn->query($sql) === TRUE) {
        echo "<script>alert('Your Message Sent Sucessfully, We will contact you soon.');</script>";
    }
    else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }
}
?>

1 个答案:

答案 0 :(得分:0)

我在你的php上做了一些改动。这将适用于你在那里输入你的邮件ID,你可以在那里发两个电子邮件ID。

const int a_size = 5; int *a = new int[a_size]