-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail.php
45 lines (37 loc) · 1.21 KB
/
mail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!-- <?php
$name = $_POST('name');
$email = $_POST('email');
$message = $_POST('message');
// $mailheader = "From:".$name."<".$email.">\r\n
// $recipient = "[email protected]";
// mail($recipient, $subject, $message, $mailheaders);
// or die("Error!");
// echo"message send";
$conn = new mysqli("localhost", "root","",'contact_form');
if($conn->connect_error){
die('Connection Failed : '.conn->connect_error);
}else{
$stmt = $conn->prepare("INSERT INTO contact(name, email, message) VALUES(?,?,?)");
$stmt->bind_param("sss", $name ,$email,$message); // s - string, i - integer, d - double, b - blob
$result = $stmt->execute();
echo "Thank you for contacting us...";
$stmt->close();
$conn->close();
}
?> -->
<?php
//get data from form
$name = $_POST['name'];
$email= $_POST['email'];
$message= $_POST['message'];
$to = "[email protected]";
$subject = "Mail From Portfolio";
$txt ="Name = ". $name . "\r\n Email = " . $email . "\r\n Message =" . $message;
$headers = "From: [email protected]" . "\r\n" .
"CC: [email protected]";
if($email!=NULL){
mail($to,$subject,$txt,$headers);
}
//redirect
header("Location:thankyou.html");
?>