メーリングリストにサインアップして詳細をデータベースに入力するメーリングリストフォームがあります。しかし、今私は、ユーザーがウェブサイト内で電子メールを作成し、メーリングリストにサインアップしたすべての人々に送ることができる管理セクションが必要です。これどうやってするの?ここでメーリングリストのサイトマネージャーを設定してお客様に一括してニュースレターを送付する方法
はもともとメーリングリストを作成するための私のコードです:
<?php
// start the session handler
require_once('dbfunction.php');
//connect to database
$conn2 = DB2();
require_once('header.php');
/*
* should we proceed with the form (if page is not submitted to itself echo the form)
*/
if (isset($_POST['submit'])) {
//detect if we have errors or not
$errors = false;
$error_msg = "Error, please try again";
if (!isset($_POST['full_name']) || $_POST['full_name'] == "") {
$errors = true;
echo "<p style='color: red; position: absolute; top:115.5em; right:28em;'>Enter your full name</p>";
}
if (!isset($_POST['email']) || $_POST['email'] == "") {
$errors = true;
echo "<p style='color: red; position: absolute; top:120.1em; right:25.7em;'>Enter an email</p>";
}
$email = $_POST['email'];
//prepare and set the query and then execute it
$stmt = $conn2->prepare("SELECT COUNT(email) FROM maillist WHERE email = ?");
$stmt->bind_param('s',$email);
$stmt->execute();
$stmt->bind_result($count);
while($stmt->fetch()){}
if(!empty($count)){
echo "<p class='red'>Email already registered, please enter an alternative email</p>";
}
else
//if we have no errors, do the SQL
if (!$errors) {
$full_name = $_POST['full_name'];
$full_name = ucfirst($full_name);
//insert data
$stmt = $conn2->prepare("INSERT INTO maillist (billing_name, email) VALUES (?, ?)");
//bind the parameters
$stmt->bind_param('ss', $full_name, $email);
// Execute query
$stmt->execute();
//if the query worked, put out the confirmation message (you can make this look however you want)
if ($stmt) {
echo "<p class='black'>Thank you for joining out mailing list</p>";
//put out the footer and then stop the rest of the script from running, so we don't display the rest of the form (this is after the form has been submitted)
require_once('footer.php');
exit;
}
}
}
自分で作成することで、新しいことを学び、開発スキルを向上させることができます。もちろん、時間と患者は必須です。 –
原則として、そうですが、顧客関係にあまり影響を与えないものは、より良い訓練の場になります。 –