私は、ユーザーの電子メールを要求し、彼の氏名、姓および携帯電話番号を送信するフォームをテストしています。今はすべてが機能しています。入力された電子メールに応じてユーザを選択します。それは電子メールを送信します。テーブルからデータを取得できません
私が抱えている唯一の問題は、送信するメールにテーブルのデータを挿入する方法です。
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'私はOK – C2486
!エラーが発生しました。 – RedZ