0

私はあなたが彼に電子メールを受け取るように構築を始めたばかりです。つまり、ページに入る前にユーザーの電子メールを承認することを意味します。

if( !isset( $user_found)) {
     //sende email til brugere
     $code = rand(111111111, 999999999);
     //sendere info til brugere.
     $to = $email;
     $subject = "Activate din brugere - .....dk";
     $headers = "From: support@...dk";
     //indhold til email
     $body = "Hej";

     if(empty($errors))
     {
         if ($stmt = $mysqli->prepare('INSERT INTO `brugere` (`email`, `password`) VALUES (?, ?)')) {
             /* Bind parametre */
             $stmt->bind_param('ss', $email, $password);

             /* Sæt værdier på parametrene */
                $email = $_POST["email"];
             $password = sha1($_POST["password"]);

             $stmt->execute();
             /* Luk statement */
             $stmt->close();

             echo "<div id=\"box\"><ul><li>Godkendt brugere</li></ul></div>";

         } else {
             /* Der er opstået en fejl */
             echo 'Der opstod en fejl i erklæringen: ' . $mysqli->error;
         }
     }
 }

これは、ユーザーが後でリンクに対して何かを行うために、$コードがマージナルコードを作成する必要があるようなものです。

<?php

if(!empty($_POST))
{              
    if ($stmt = $mysqli->prepare('SELECT * FROM `brugere` WHERE `email` = ?')) {  
        $stmt->bind_param('s', $email);
        $email = $_POST['email'];
        $stmt->execute();
        $stmt->store_result();
        $count = $stmt->num_rows;
        $stmt->close();
         if ($count > 0)
        {
            $user_found = 1;
        }
    }
    else {
        /* Der er opstået en fejl */
        echo 'Der opstod en fejl i erklæringen: ' . $mysqli->error;
    }
    if(!isset($user_found)) {

        //sendere info til brugere.
        $to = $email;
        $subject = "Activate din brugere - .....dk";
        $headers = "From: support@...dk";
        //indhold til email
        $body = "test";


        if(empty($errors))
        {
            if ($stmt = $mysqli->prepare('INSERT INTO `brugere` (`email`, `password`, `code`) VALUES (?, ?, ?)')) {
                /* Bind parametre */
                $stmt->bind_param('ss', $email, $password, $code);

                /* Sæt værdier på parametrene */
                $email = $_POST["email"];
                $password = sha1($_POST["password"]);
                $code;

                $stmt->execute();
                /* Luk statement */
                $stmt->close();

                echo "<div id=\"box\"><ul><li>Godkendt brugere</li></ul></div>";

            } else {
                /* Der er opstået en fejl */
                echo 'Der opstod en fejl i erklæringen: ' . $mysqli->error;
            }
        }
    }
    else {
        echo "<div id=\"box\"><ul><li>Der findes allerede en bruger med denne mail</li></ul></div>";
    }
}

?>

それが私のコードのようです、

私がこれから欲しいのは、データベース内の$コードであり、ユーザーに電子メールが送信されます...

ここでそれについてもっと学ぶことがあるかどうか尋ねてください。

結局のところ、質問をします。

    <?php
// multiple recipients
$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
    <tr>
      <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
    </tr>
    <tr>
      <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
    </tr>
    <tr>
      <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
    </tr>
  </table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>

メールを使用するためだけにこれを行うにはどうすればよいですか?$ to ='aidan@example.com'

4

1 に答える 1

0

まず第一に、あなたが英語で出力を書くことができればそれはより良いでしょう。

次のようなメールでクエリ文字列を送信します

yourpage.php?user = someuserid&code = randomcode

ユーザーが提供されたクエリ文字列を通過したかどうかをページにチェックインするだけです。彼が直接来た場合は、エラーページに送ってください。次に、rand関数を使用して作成したコードを確認します。それが存在する場合は、ページにコンテンツを表示します。

コードは次のようになります。

<?php
if(empty($error))
{
show_content();
}
?>

または、ユーザーを任意のページにリダイレクトできるものなら何でも。

クエリ文字列をチェックするためのコード。

<?php
if(!isset($_GET['qstring'])) // qstring for query string name
{
// redirect to error page
}
else
{
$qstring = $_GET['qstring'];


//$res_code= mysql_query ()........... (result of )
//check for availability of your random code and the userid in your database table\
if(mysql_num_rows($res_code) > 0)
{
show_content();
}
else
{
//again redirect to error page or index page.
}
}
?>

コードが利用可能な場合は、コンテンツを表示します。ifの代わりにswitchcaseを使用できます。それはあなた次第です。

これがあなたの相棒に役立つことを願っています。

于 2012-04-28T16:27:33.083 に答える