基本的に、ユーザーがサインアップできる登録フォームがあり、登録ごとに一意の確認コードがデータベースに生成され、サインアップ時にユーザーに電子メールで送信されます。
私は現在、ユーザーが電子メールのリンクをクリックしてverification.phpに移動する第2段階に取り組んでいます
このページで、ユーザーは電子メールで送信された検証/登録コードを入力する必要があります。ここにあるスクリプトは、検証コードを探して、データベースにあるものと一致することを確認する必要があります。
私がやりたいことは、確認コード/登録コードがデータベースに保持されているものと正しい場合、その確認コードに一致するそのユーザーのために保持している電子メールアドレスに確認メールを送信することをクエリに伝えることです. (同じ確認コードを持つその行に属する電子メールです。)
私のテーブルはこんな感じ
id email registration_code (verification code)
1 example@email.com 5093dkfd
現在、クエリはデータベースに保持されている登録コードを検索しますが、その登録コードに一致する電子メールを見つけて電子メールを送信する方法がわかりません。このビット私は助けが必要です。誰でも私を正しい方向に向けてください、
また、クエリで、コードを正しく入力したかどうかをユーザーに伝えたいと思っています。
/**
* ShuttleCMS - A basic CMS coded in PHP.
* Verification Code Check - Used to confirm a user's verification code
*
*/
define('IN_SCRIPT', true);
// Start a session
session_start();
//Connect to the MySQL Database
include 'includes/_config/connection.php';
/*
* Checks form field for verification code, then where verification code has email, send email to recipient
*/
if ($_POST['verificationcode']=='') {
header('Location: verification.php?err=1');
}
if(get_magic_quotes_gpc()) {
$verificationcode = htmlspecialchars(stripslashes($_POST['verificationcode']));
}
else {
$verificationcode = htmlspecialchars($_POST['verificationcode']);
}
/*
* Checks if the verification code exists and look for email in that row which belongs to that verification code to send email out.
*/
$sql = "SELECT COUNT(*) FROM ptb_registrations WHERE registration_code = '$verificationcode' AND '$verificationcode' MATCHES email";
$result = mysql_query($sql)or die('Could not find member: ' . mysql_error());
if (!mysql_result($result,0,0)>0) {
header('Location: verification.php?err=2');
}
次に、確認メールを送信します。
/*
* Email out the infromation
*/
(EMAIL BODY)
YOUR code was matched and you are now registered etc.