2012-10-17 2 views
1

사용자 비밀번호를 한 번 묻는 웹 사이트 등록 양식을 만들고, 제출을 클릭하면 자바 스크립트 상자가 나타나 사용자에게 다시 묻고 확인합니다. 이전 페이지와 비교하여 동일하지 않은 경우 조인 페이지에 머무르며 비밀번호가 일치하지 않는다고 알립니다. 이 일을 어떻게 하죠?자바 스크립트 팝업 암호 확인

<?php 

$errorMsg = ""; 

// First we check to see if the form has been submitted 

if (isset($_POST['companys_name'])){ 

    //Connect to the database through our include 

    include_once "connect_to_mysql.php"; 

    // Filter the posted variables 

    $companys_name = preg_replace("[^A-Za-z0-9]", "", $_POST['companys_name']); // filter everything but numbers and letters 

    $admin_first_name = preg_replace("[^A-Za-z]", "", $_POST['admin_first_name']); // filter everything but letters 

    $admin_phone = preg_replace("[^0-9]", "", $_POST['admin_phone']);// Filters everything except numbers 

    $admin_email = preg_replace("[^A-Z a-z0-9]", "", $_POST['admin_email']); // filter everything but spaces, numbers, and letters 

    $admin_url = preg_replace("[^A-Z a-z0-9]", "", $_POST['admin_url']); // filter everything but spaces, numbers, and letters 

    $admin_last_name = preg_replace("[^A-Z a-z]", "", $_POST['admin_last_name']); // filter everything but spaces, numbers, and letters 

    $admin_email = stripslashes($_POST['admin_email']); 

    $admin_email = strip_tags($admin_email); 

    $admin_email = mysql_real_escape_string($admin_email); 

    $admin_password = preg_replace("[^A-Za-z0-9]", "", $_POST['admin_password']); // filter everything but numbers and letters 

    // Check to see if the user filled all fields with 

    // the "Required"(*) symbol next to them in the join form 

    // and print out to them what they have forgotten to put in 

    if((!$companys_name) || (!$admin_first_name) || (!$admin_phone) || (!$admin_last_name) || (!$admin_email) || (!$admin_password)){ 



     $errorMsg = "You did not submit the following required information!<br /><br />"; 

     if(!$companys_name){ 

      $errorMsg .= "--- Company Name"; 

     } else if(!$admin_first_name){ 

      $errorMsg .= "--- Phone Number 10 Digits"; 

     } else if(!$admin_phone){ 

      $errorMsg .= "--- Phone Number 10 Digits"; 

     } else if(!$admin_last_name){ 
      $errorMsg .= "--- Last Name"; 

     } else if(!$admin_email){ 

      $errorMsg .= "--- Email Address"; 

     } else if(!$admin_password){ 

      $errorMsg .= "--- Password"; 

     } 



    } else { 

    // Database duplicate Fields Check 

    $sql_companys_name_check = mysql_query("SELECT id FROM toc_companys WHERE companys_name='$companys_name' LIMIT 1"); 

    $sql_admin_email_check = mysql_query("SELECT id FROM toc_companys WHERE admin_email='$admin_email' LIMIT 1"); 

    $companys_name_check = mysql_num_rows($sql_companys_name_check); 

    $admin_email_check = mysql_num_rows($sql_admin_email_check); 

    if ($companys_name_check > 0){ 

     $errorMsg = "<u>ERROR:</u><br />Your company name is already in use inside our system. Please try another."; 

    } else if ($admin_email_check > 0){ 

     $errorMsg = "<u>ERROR:</u><br />Your Email address is already in use inside our system. Please try another."; 

    } else { 

     // Add MD5 Hash to the password variable 

     //$hashedPass = md5($password); 

     // Add user info into the database table, claim your fields then values 

     $sql = mysql_query("INSERT INTO toc_companys (companys_name, admin_first_name, admin_phone, admin_url, admin_last_name, admin_email, admin_password) 

     VALUES('$companys_name', '$admin_first_name', '$admin_phone','$admin_url','$admin_last_name', '$admin_email','$admin_password', now())") or die (mysql_error()); 

     // Get the inserted ID here to use in the activation email 

     $id = mysql_insert_id(); 

     // Create directory(folder) to hold each user files(pics, MP3s, etc.) 

     mkdir("memberFiles/$id", 0755); 

     // Start assembly of Email Member the activation link 

     $to = "$admin_email"; 

     // Change this to your site admin email 

     $from = "[email protected]"; 

     $subject = "Activate your account!"; 

     //Begin HTML Email Message where you need to change the activation URL inside 

     $message = '<html> 

     <body bgcolor="#FFFFFF"> 

     Hi ' . $admin_first_name . ' at ' . $companys_name . ', 

     <br /><br /> 

     You must complete this step to activate your account with us. 

     <br /><br /> 

     Please click here to activate now &gt;&gt; 

     <a href="http://www.testsite.com/activation.php?id=' . $id . '"> 

     ACTIVATE NOW</a> 

     <br /><br /> 

     Your Login Data is as follows: 

     <br /><br /> 

     E-mail Address: ' . $admin_email . ' <br /> 

     Password: ' . $admin_password . ' 

     <br /><br /> 

     Thanks! 

     </body> 

     </html>'; 

     // end of message 

     $headers = "From: $from\r\n"; 

     $headers .= "Content-type: text/html\r\n"; 

     $to = "$to"; 

     // Finally send the activation email to the member 

     mail($to, $subject, $message, $headers); 

     // Then print a message to the browser for the joiner 

     print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> 

     We just sent an Activation link to: $admin_email<br /><br /> 

     <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> 

     Link inside the message. After email activation you can log in."; 

     exit(); // Exit so the form and page does not display, just this success message 

    } // Close else after database duplicate field value checks 

    } // Close else after missing vars check 

} //Close if $_POST 

?> 

선생님은 누군가가 레지스터를 클릭 그렇게 할 때 자바 스크립트를 만들기 위해 저를 원하는 : 여기

<h2>New Account Registration.</h2> 

      <table width="600" cellpadding="1" style="text-align:center;"> 
    <form action="join.php" method="get" > 
    <tr> 
     <td colspan="1"><font color="#FF0000"></font></td> 
    </tr> 
    <tr> 
     <td>Company Name:</td> 
     </tr> 
     <tr> 
     <td><input style="background-color: #FFF;" name="companys_name" type="text" placeholder="Google" required /></td> 
    </tr> 
    <tr> 
     <td>First Name:</td> 
     </tr> 
     <tr> 
     <td ><input style="background-color: #FFF;" name="admin_first_name" type="text" placeholder="John" required /> 
     </td> 
    </tr> 
    <tr> 
     <td>Last Name: </td> 
     </tr> 
     <tr> 
     <td> 
     <input style="background-color: #FFF;" name="admin_last_name" type="text" placeholder="Doe" required /> 
     </td> 
    </tr> 

    <tr> 
     <td>Phone Number:</td> 
     </tr> 
     <tr> 
     <td><input style="background-color: #FFF;" type="tel" name="admin_phone" pattern="[0-9]{3}-?[0-9]{3}-?[0-9]{4}" required placeholder="123-123-1231"></td> 
    </tr> 
    <tr> 
     <td>Website: </td> 
     </tr> 
     <tr> 
     <td><input style="background-color: #FFF;" type="url" id="orderWebsite" placeholder="http://domain.com" /></td> 
    </tr> 

    <tr> 
     <td>Email: </td> 
     </tr> 
     <tr> 
     <td><input style="background-color: #FFF;" type="email" id="orderEmail" placeholder="[email protected]" required /></td> 
    </tr> 
    <tr> 
     <td> Password: </td> 
     </tr> 
     <tr> 
     <td> <input style="background-color: #FFF;" name="admin_password" type="password" required /> 
     </td> 
    </tr> 
    <tr> 
     <td><input type="submit" name="Submit" value="Register!" onclick="register()" /></td> 
    </tr> 
    </form> 
</table> 

그것은에 연결하는 PHP 페이지입니다 : 여기

는 내가 가지고있는 HTML 문서입니다 상자가 나타나면 입력 상자와 비교하여 암호를 다시 입력하도록 요청하는 팝업이 나타나고, 입력 상자가 동일하면 계정을 만들지 않으면 페이지를 떠나지 않지만 암호가 맞지 않는다고 말할 것입니다 똑같다.

+1

당신은 시도? 지금까지 뭐라구? "팝업"이란 대화 상자, 새 창 또는 "팝 오버"(같은 페이지의 겹쳐진 요소)를 의미합니까? – Kitsune

+0

비밀번호를 확인하는 자바 스크립트 상자 (사용자가 html로 넣은 것) –

답변

3

JQuery와 통해 의사 코드 : 양식에 대한

$('#submit').click(function(){ 
    $('#box').show(); 
}); 

$('#box > #confirm').click(function(){ 
    var firstInput = $('#firstInput').val(); 
    var secondInput = $('#secondInput').val(); 
    if(!firstInput.equal(secondInput)) { 
    //do something if they are not the same 
    } 
}); 
+0

내가 필요로하는 것이 실제로는 없습니다 :/ –

+0

다른 대답을 시도해보십시오. – zetsin

0

세트 ID 및 상자 추가 : .html 중에서 하단에

<form id="myform" action="join.php" method="get" > 
... 
</form> 
<div id="box" style="display: none; width: 100px; height: 100px; backgournd-color: #FFFFFF;"> 
    <input id="confirmPassword"/> 
    <span id="info"></span> 
    <button id="confirm">confirm</button> 
</div 

추가 스크립트가 무엇

$('#myform').submit(function(){ 
    $('#box').show(); 
    return false; // cancel the submit action 
}); 
$('confirm').click(function(){ 
    if($('input[value="admin_password"]').val().equal($('#confirmPassword').val())) { 
    $('#myform').submit(); // to submit the form here 
    } else { 
    $('#info').text("passwords are not the same!").show().fadeOut(1000); 
    } 
});