Forum Sementara Putera.com

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Forum Sementara Putera.com

Bersama kita perkemaskan forum ini sementara forum asal dalam pemulihan.

Forum putera dah kembali. Masalah sudah berjaya diselesaikan. Sila lawati http://forum.putera.com/tanya


2 posters

    javascript php for auto generated password

    avatar
    jeliey
    Ahli Baharu
    Ahli Baharu


    Number of posts : 26
    Registration date : 01/04/2009

    javascript php for auto generated password Empty javascript php for auto generated password

    Post by jeliey Tue Jul 27, 2010 1:26 pm

    hi guys...

    sy sangat2 memerlukan bantuan,urgent matter...Sad

    Sy ada 2 tables iaitu account & contract.

    sy nak create auto-generate password apabila user click checkbox utk create password.

    After, they click save button, the generated password will be displayed in the text field provided. For username, i want to retrieve email address from account's table. I'm sure i must join this table together, rite?

    Lastly, i want to insert these password and username in the contract table.

    Masalah sy sekarang ialah, sy nk javascript yg boleh buat function ni...sy dh try tp tak jadi pun

    harp sgt2 someone here can help me pale


    Thanx
    ahaksz28
    ahaksz28
    Moderators
    Moderators


    Gender : Male Number of posts : 507
    Location : Rumah Parent
    Job/hobbies : Gaming
    Registration date : 13/02/2009

    javascript php for auto generated password Empty Re: javascript php for auto generated password

    Post by ahaksz28 Tue Jul 27, 2010 1:52 pm

    post coding yang dah dibuat tu sini.. kami try tengok.. Smile
    avatar
    jeliey
    Ahli Baharu
    Ahli Baharu


    Number of posts : 26
    Registration date : 01/04/2009

    javascript php for auto generated password Empty Re: javascript php for auto generated password

    Post by jeliey Tue Jul 27, 2010 2:04 pm

    Code:
    <?php
    function generateRandStr($length)
    {
        $randstr = "";
        for($i=0; $i<$length; $i++)
       {
            $randnum = mt_rand(0,61);
            if($randnum < 10){
              $randstr .= chr($randnum+48);
            }else if($randnum < 36){
              $randstr .= chr($randnum+55);
            }else{
              $randstr .= chr($randnum+61);
            }
        }
        return $randstr;
    }
    ?>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
    <html>
    <body>
          <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
             <table>
              <tr>
                <td>
                   <input type="checkbox" name="password" <?php echo $selected['password']?> value="password">Generate Password<br>            
                </td>         
              </tr>
              <tr>
                 <td >
                    <br/><input type="submit" name="submitBtn" value="Submit"><br>
                 </td>
              </tr>
            </table>
          </form>
    <?php   
        if ((isset($_POST['submitBtn'])) && (isset($_POST['password'])))
        {
           $selected['password']="checked";
              
          $password = generateRandStr(8);
          echo $password;
        }
    ?>
    </body> 

    yg ni sy try sebelum apply kat original code...tp yg ni saya cuma buat utk generate password je...

    Sponsored content


    javascript php for auto generated password Empty Re: javascript php for auto generated password

    Post by Sponsored content


      Current date/time is Mon Nov 18, 2024 4:28 am