没有邮件功能插入查询工作正常,但使用邮件功能,该页面将无法正常工作页面无法处理此请求。提供HTTP ERROR 500,它会在每次新注册时向我们发送电子邮件。
<?php
require_once 'sessions.php';;
$servername = "localhost";
$username = "medmocksroot";
$password = "medmocks123";
$dbname = "medmocks";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO student (Name,Contact,email,Password)
VALUES ('$_POST[name]','$_POST[contact]','$_POST[email]','$_POST[password]')";
if ($conn->query($sql) === TRUE) {
$_SESSION['message'] = "Request Submitted Successfully";
} else {
$_SESSION['message'] = "Error: " . $sql . "<br>" . $conn->error;
}
/*header("Location: signup.php");*/
if (isset($_REQUEST['signup_mail'])) {
//Email information
$admin_email = "medmocks7@gmail.com";
$name = $_REQUEST['name'];
$subject = "New Signup";
$email = $_REQUEST['email'];
$contact = $_REQUEST['contact'];
$pass = $_REQUEST['password'];
//send email
$sql = mail("medmocks7@gmail.com", "Subject:" .$subject, "From:" .$email, "Name:" .$name, "Contact:" .$contact, "Password:" .$pass);
if ($conn->query($sql) === TRUE) {
header("Location:signup.php");
echo '<script language="javascript">';
echo 'alert("Message Sent Successfully")'; //not showing an alert box.
echo '</script>';
exit;
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();