1

登録フォームに少し問題があります。ユーザーがアカウントをアクティブ化するための確認メールが送信されたときに、ユーザーが入力したとおりにUserIDフィールドを表示しようとしています。現在、確認メールに表示する必要があるのは、ユーザーが指定したUserIDとランダムに生成されたPINのみです。PINは電子メールに正しく表示されますが、ユーザーIDは表示されないため、誰かがこれを修正できますか。

以下は私のコードです:

<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 of your BFS Account'; // Give the email a subject  
$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. 
------------------------ 
USER ID: '.$UserID.' // **THIS IS WHERE I HAVE THE PROBLEM DISPLAYING USER ID**
PIN: '.$PIN.' 
------------------------ 
Please click this link to activate your account: 
http://www.website.com/verify.php?email='.$email.'&hash='.$hash.' 
'; // Our message above including the link  
$headers = 'From:noreply@website.com' . "\r\n"; // Set from headers  
mail($to, $subject, $message, $headers); // Send our email  

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

    </div>
4

1 に答える 1

1

に何も割り当てていません$UserID。大まかな推測として、次のことが必要になる場合があります。

$UserID = $_POST['userid']; //  or
$UserID = $_POST['user_id'];

PSコードのインデントに取り組んでください。

于 2013-02-26T11:52:01.683 に答える