2013-02-26 58 views
1

我的注册表单有点问题:我正在尝试获取用户输入的用户ID字段,当验证电子邮件发送给用户激活帐户。 目前,我只需要用户提供的用户标识和随机生成的个人识别码显示在验证邮件中。请任何人都可以为我纠正这一点,因为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:[email protected]' . "\r\n"; // Set from headers 
mail($to, $subject, $message, $headers); // Send our email 

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

    </div> 
+0

$ UserId分配的值在哪里? – 2013-02-26 11:51:23

+0

我看不到任何声明,初始化,赋值,关于变量'$ UserID'的任何事情,你在哪里给这个变量赋值? – Naryl 2013-02-26 11:54:25

回答

1

你不$UserID分配什么。作为一个疯狂的猜测你可能需要:

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

P.S请在你的代码缩进工作。

+0

谢谢你们,但我该如何声明或分配UserID?因为与我声明的散列和PIN不同,用户ID由用户提供,并且只需从表单中检索并发送到电子邮件地址。 – Kaos 2013-02-26 12:10:18

+0

我已经声明了UserID:$ UserID = $ _POST ['UserID']; \t但是我仍然得到一个错误:(!)注意:未定义的索引:UserID在C:\ wamp \ www \ ONLINE BANKING \ registration.php在528行。我仍然想不出我做错了什么。对不起,代码缩进。我使用记事本++,并且缩进并不那么容易。 – Kaos 2013-02-26 12:12:15

+0

确保您的表单正在发送'UserID'。例如,您可能需要添加 Kurt 2013-02-27 02:43:09

相关问题