Jump to content

Repeat password = password ?


Davie33

Recommended Posts

Hi all hope you can help.

For repeat password i was trying get repeat password to check if its the same as password if not same then you must enter password again.

How do i code this in and what line would i add it too ?.

<div id="center">
    <div class="container_box1">
    <div id="headergames2">Register:</div>
        <div class="containbox"><noscript>
            <?php
            if (isset($_POST['submit'])) {
                if ($_POST['recaptcha'] == 'yes') {    
                    include($setting['sitepath']."securimage.php");
                    $img = new Securimage();
                    $valid = $img->check($_POST['code']);
                    if (!$valid) {
                        $passed = false;
                    } else {
                        $passed = true;
                    }
                }
                elseif ($_POST['recaptcha'] == 'no') {
                    $answer = array('10', 'ten');
                    if(!in_array(strtolower($_POST['security']),$answer)) {
                        $passed = false;
                    } else {
                        $passed = true;
                    }
                }
                if ($_POST['username']=='' || $_POST['password']=='' || $_POST['repeatpassword']=='') {
                    ?><script>alert("Sorry username or password,repeatpassword is empty!!");</script>
                    <META HTTP-EQUIV="Refresh" CONTENT="0; URL=<?php echo $setting['siteurl'].'index.php?act=register';?>">
                    <?php
                    exit;
                }
                if ($passed) {
                    $id  = yasDB_clean($_POST["id"]);
                    $username = yasDB_clean($_POST["username2"]);
                    $password = md5(yasDB_clean($_POST["password"]));
                    $repeatpassword = md5(yasDB_clean($_POST["repeatpassword"]));
                    $name = yasDB_clean($_POST["name"]);
                    $email = yasDB_clean($_POST["email"]);;
                    $website = yasDB_clean($_POST["website"]);
                    $date = time() + (0 * 24 * 60 * 60);  
                    $plays = 0;
                    $points = 0;
                    $randomkey = rand(13649875,98732458);
                    $headers = 'From: '.$setting['sitename'].' <'.$setting['sitename'].'>';
                    $subject = 'Activate your account at '. $setting['siteurl'];                    
                    $body = '
                    Thank you for becomming a member here at '.$setting['sitename'].'\r\n
                    We hope you enjoy our site and what we have to offer.\r\n>
                    To activate your account click the link below:\r\n
                    '.$setting{'siteurl'}.'activated.php?id='.$id.'=code='.$randomkey.'
                    \r\n
                    Thanks,
                    Admin:';                    
                    mail($email, $subject, $body, $headers);
                    $stmt=yasDB_select("SELECT * FROM user WHERE username LIKE '$username'");
                    if($stmt->num_rows == 0){
                        $stmt = yasDB_insert("INSERT INTO `user` (username, password, repeatpassword, name, email, website, plays, points, date, randomkey, activated) VALUES ('$username','$password','$repeatpassword','$name','$email','$website','$plays','$points', '$date', $randomkey, '0')",false);
                        if ($stmt) {
                            ?><script>alert("Registered: Please check email to activate your account!");</script>
                            <META HTTP-EQUIV="Refresh" CONTENT="0; URL=<?php echo $setting['siteurl'];?>">
                            <?php
                            exit;
                        } else {
                            $stmt->close();
                            ?><script>alert("Action Failed");</script>
                            <META HTTP-EQUIV="Refresh" CONTENT="0; URL=<?php echo $setting['siteurl'].'index.php?act=register';?>">
                            <?php
                            exit;
                        }
                    } else {
                        $stmt->close();
                        ?><script>alert("Sorry username or email exists try again!!");</script>
                        <META HTTP-EQUIV="Refresh" CONTENT="0; URL=<?php echo $setting['siteurl'].'index.php?act=register';?>">
                    <?php }
                }
            }
            ?></noscript>
           <div id="preview"></div><div id="contactBox">
          <?php
          if ($setting['regclosed'] == 'yes') {
          echo '<center>Registration is now closed.</center>';
          } else {
          ?>
           <form name="myform" id="form" action="index.php?act=register" method="post" >
             Username: <br />
             <input class="blue" type="text" name="username2" id="username2" size="35" /><br />
             Password: <br />
             <input class="formsheader" type="password" name="password" id="password" size="35" />
             <Br />
             Repeat Password: <br />
             <input class="formsheader" type="password" name="repeatpassword" id="repeatpassword" size="35" />
             <Br />
             Name: <br />
             <input  type="text" name="name" size="35" />
             <br />
             Email: <br />
             <input  type="text" name="email" id="email" size="35" />
             <br />
             Website :<br />
             <input  type="text" name="website" size="35" />
             <br /><br />
              <?php
             if ($setting['userecaptcha'] == "yes") {
                @session_start();
                // securimage captcha
                ?>
                <div style="width: 700px; float:left;height: 90px">
                <img id="siimage" align="center" style="padding-right: 5px; border: 0" src="<?php echo $setting['siteurl']; ?>includes/securimage/securimage_show.php?sid=<?php echo md5(time()) ?>" />
                <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="19" height="19" id="SecurImage_as3" align="middle">
                    <param name="allowScriptAccess" value="sameDomain" />
                    <param name="allowFullScreen" value="false" />
                    <param name="movie" value="<?php echo $setting['siteurl']; ?>securimage_play.swf?audio=securimage_play.php&bgColor1=#fff&bgColor2=#284062&iconColor=#000&roundedCorner=5" />
                    <param name="quality" value="high" />            
                    <param name="bgcolor" value="#284062" />
                    <embed src="<?php echo $setting['siteurl']; ?>securimage_play.swf?audio=securimage_play.php&bgColor1=#fff&bgColor2=#284062&iconColor=#000&roundedCorner=5" quality="high" bgcolor="#284062" width="19" height="19" name="SecurImage_as3" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
                 </object>
                <!-- pass a session id to the query string of the script to prevent ie caching -->            
                <a tabindex="-1" style="border-style: none" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = '<?php echo $setting['siteurl']; ?>includes/securimage/securimage_show.php?sid=' + Math.random(); return false"><img src="<?php echo $setting['siteurl']; ?>includes/securimage/images/refresh.gif" alt="Reload Image" border="0" onclick="this.blur()" align="middle" /></a>
                <div style="clear: both"></div>
                </div>            
                Security Code:<br />
                <input type="text" name="code" id="code" size="12" /><br /><br />
                <input name="recaptcha" type="hidden" value="yes" /><?php
                // end securimage captcha
        }
        else {
                ?>Security Question: five + five = <br />
                <input name="security" id="security" type="text" style="border: 1px solid #000;" /><br/>
                <input name="recaptcha" type="hidden" value="no" /><?php
        }?>
             <br/>   
             <input type="submit" name="submit" value="Sign Up" />
          </form>
          <br/>*Email is used to reset a forgotten password only.       
<?php } ?>
    </div></div>

    <div class="clear"></div>

    </div>
Edited by Davie33
Link to comment
Share on other sites

Am not too sure but i think am on the right path with this.

Any help would be gr8t thanks.

                if ($_POST['password'] != $_POST['repeatpassword']) {
                    ?><script>alert("Sorry password,repeatpassword does not match!");</script>
                    <META HTTP-EQUIV="Refresh" CONTENT="0; URL=<?php echo $setting['siteurl'].'index.php?act=register';?>">
                    <?php
                    exit;
                }
Edited by Davie33
Link to comment
Share on other sites

There are a many problems with this page. Md5 should not be used for password hashing. 

Here is a quick fix for what you are attempting however.

    $user = $_POST['username'];
                $pswd = $_POST['password'];
                $repeat_pswd = $_POST['repeatpassword'];

                if ($user == '' || $pass == '' || $repeat_pswd == '') {
                    ?><script>alert("Sorry username or password,repeatpassword is empty!!");</script>
                <?php
                }
                elseif(($pswd != '' && $repeat_pswd != '') && ($pswd != $repeat_pswd))
                {
                ?><script>alert("Password fields do not match");</script>
                <?php } ?>
Link to comment
Share on other sites

You are using php to setup error handling messages in JS. Why? You do realize that you can't have php and JS interact in real time?

 

If you want a real time error message then stick only with the JS code to check the values onsubmit. If you don't want real time, then stick to only php to edit the posted values and send the screen and data back to the user. Can't have it both ways.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.