3

私は、ユーザーがアカウントにサインアップする必要がある小さな Web サイトに取り組んでいます。その後、アカウントを確認するための詳細が記載された電子メールがユーザーに送信されます。確認メールのリンクをクリックすると、アカウントがアクティブになり、ユーザーがログインできるようになります。registration.php(登録するため)、login.php(ログインするため)、verify.php(アカウントのアクティベーションを確認するため)から3つのPHPスニペットを提供しました!! 私はWAMPサーバーを使用してデータベースとそれに応じたテーブルを作成しています

注: これは、登録ページで受け取る唯一のエラーです。

警告: mail(): 「localhost」ポート 25 でメールサーバーに接続できませんでした。php.ini で「SMTP」と「smtp_port」の設定を確認するか、C:\wamp\www\ONLINE BANKING\registration で ini_set() を使用してください。 php 541行目

現在、いくつかの問題があります: 1. hmailserver を使用していますが、設定方法がよくわかりません 2. ユーザーがいつデータベースに追加されたかを監視する必要があります (これは、電子メール確認リンクがクリックされます)

私が間違っていることと、これを修正する方法を教えてください

**REGISTRATION.PHP**

     <div id="wrap">
                <!-- start PHP code -->
                <?php

                    mysql_connect("localhost", "root", "") or die(mysql_error()); // Connect to database server(localhost) with root .
                    mysql_select_db("registrations") or die(mysql_error()); // Select registration database.

                    $email="";

                    if( isset($_POST['fullname']) // Is the name field being posted; it does not matter whether it's empty or filled.  
            && // This is the same as the AND in our statement; it allows you to check multiple statements.  
            !empty($_POST['fullname']) // Verify if the field name is not empty 
            AND isset($_POST['email']) // Is the email field being posted; it does not matter if it's empty or filled.  
            && // This is the same as the AND in our statement; it allows you to check multiple statements.  
            !empty($_POST['email']) ) // Verify if the field email is not empty   
              {

                        $fullname = mysql_real_escape_string($_POST['fullname']);
                        $email = mysql_real_escape_string($_POST['email']);

                        }
                        if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email)){
                            // Return Error - Invalid Email
                            $msg = 'The email you have entered is invalid, please try again.';
                        }else{
                            // Return Success - Valid Email
                            $msg = 'Your account has been created, <br /> please verify it by clicking the activation link that has been send to your email.';
                            }

                            $hash = md5( rand(0,1000) ); // Generate random 32 character hash and assign it to a local variable.

                            $PIN = rand(1000,5000); // Generate random number between 1000 and 5000 and assign it to a local variable.

        $to      = $email; // Send email to our user  
        $subject = 'Signup | Verification'; // Give the email a subject  
        $from="info@bfs.com";
        $message = 'Thanks for signing up! 
        Your account has been created, you can login with the following credentials after you have activated your account by clicking the url below. 
        ------------------------ 
        echo $_POST["UserID"];
        PIN: '.$PIN.' 
        ------------------------ 
        Please click this link to activate your account: 
        http://www.yourwebsite.com/verify.php?email='.$email.'&hash='.$hash.' 
        '; // Our message above including the link  
        $headers = 'From:noreply@yourwebsite.com' . "\r\n"; // Set from headers  
        mail($to, $subject, $message, $headers); // Send our email  //Line 541

                ?>
                <!-- stop PHP Code -->   


            </div>

**LOGIN.PHP**
<div id="wrap">
        <!-- start PHP code -->
        <?php

            mysql_connect("localhost", "root", "") or die(mysql_error()); // Connect to database server(localhost) with UserID and PIN.
            mysql_select_db("registrations") or die(mysql_error()); // Select registration database.

            if(isset($_POST['name']) && !empty($_POST['name']) AND isset($_POST['PIN']) && !empty($_POST['PIN'])){
                $UserID = mysql_escape_string($_POST['name']);
                $PIN = mysql_escape_string(md5($_POST['PIN']));

                $search = mysql_query("SELECT UserID, PIN, active FROM users WHERE UserID='".$UserID."' AND PIN='".$PIN."' AND active='1'") or die(mysql_error()); 
                $match  = mysql_num_rows($search);

                if($match > 0){
                    $msg = 'Login Complete! Thanks';
                }else{
                    $msg = 'Login Failed!<br /> Please make sure that you enter the correct details and that you have activated your account.';
                }
            }


        ?>
        <!-- stop PHP Code -->
        <?php 
            if(isset($msg)){ // Check if $msg is not empty
                echo '<div class="statusmsg">'.$msg.'</div>'; // Display our message and add a div around it with the class statusmsg
            } ?>

    </div>

**VERIFY.PHP**
4

3 に答える 3

1

既に Web ホスティング アカウントをお持ちの場合は、Gmail または Yahoo a/c を使用してオンラインで試すことができます。デスクトップで電子メールを設定するのは多忙で時間がかかります。

于 2013-02-25T21:22:05.230 に答える
0

あなたのウェブページを作成してください (ログインページ、登録ページ、メインページ) が必要です:

1- ユーザー名、電子メール、パスワード、パスワードの再入力、性別、生年月日のデータの登録フォームに検証を適用します。

2- ユーザー名とパスワードを使用してフォーム データにログインし、ログイン セッションを作成するための検証。

3- ユーザー情報を保存し、ログイン データを検証するために、データベース接続が確立されます。

4- メイン ページへの制限と、ログインが成功した場合にのみ許可されるアクセス。

5- メイン ページからログアウトし、ユーザー セッションを破棄します。

moyasar_22@hotmail.com

于 2016-02-17T13:37:54.597 に答える