사용자의 이메일을 요구 한 다음 이름, 성 및 핸드폰 번호를 보내는 양식을 테스트하고 있습니다. 이제 모든 것이 작동합니다. 입력 된 이메일에 따라 사용자를 선택합니다. 이메일을 보냅니다.테이블에서 데이터를 가져올 수 없습니다.
유일한 문제는 내가 보내는 데이터에 테이블의 데이터를 삽입하는 것입니다.
Eg.$mail->Body = "Your company details are: " Name,Surname,Cellphone;
내가 현재 직면 한 문제입니다. 내 전체 코드는 아래와 같습니다.
나는 PHP에서 아직 완전히 익숙하지 않기 때문에 일반적인/일반적인 오류 일 경우 사과드립니다.
<?php
error_reporting(1);
ini_set('error_reporting', E_ALL);
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="****"; // Mysql password
$db_name="Username"; // Database name
$tbl_name="Name"; // Table name
// Connect to server and select databse.
$conn = mysqli_connect($host, $username, $password, $db_name);
// Define $username and $password
$username=$_POST['user_name'];
$sql="SELECT * FROM $tbl_name WHERE Name='$username'";
$result=mysqli_query($conn, $sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
if ($count > 0)
{
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "****"; // SMTP server // enables SMTP debug information
$mail->SMTPAutoTLS = false;
$mail->SMTPSecure = false;
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "****"; // sets the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "****"; // SMTP account username
$mail->Password = "****"; // SMTP account password
$mail->From = "Test";
$mail->FromName = "Test";
$mail->AddAddress($username, "");
$mail->isHTML(true);
$mail->Subject = 'Out Of Office Password';
$mail->Body = "Your Out Of Office password: ";
if(!$mail->Send())
{
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit();
}
else
{
echo 'Email Sent Successfully!';
}
}
>
형태 :
이<center>
<html>
<head>
<title>User Information</title>
</head>
<body>
<form action="check-user.php" method="POST">
<h3>User Information</h3>
Email: <input type="text" name="user_name"><br>
<input type="submit" name="submit" value="Send Info">
</form>
</body>
</html>
</center>
'mysql' =='내가 – C2486
@Niklesh을 mysqli'하지만 지금은 내 이메일 – RedZ