Password Reset for members.
Posted: Thu Aug 23, 2012 9:17 am
I was following this tutorial by Temor
http://betterphp.co.uk/board/viewtopic.php?f=25&t=1640
And I tried to write up the change password page and update function.
This is what I have got so far.
The password reset front end page.
Thanks.
http://betterphp.co.uk/board/viewtopic.php?f=25&t=1640
And I tried to write up the change password page and update function.
This is what I have got so far.
The password reset front end page.
<?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/members/includes/header.php"; include_once($path); ?> <html> <body> <form action="for.php" method="post" class="registration_form"> <fieldset> <legend>Change Your Password</legend> <p>Change Your Password<span style="background:#EAEAEA none repeat scroll 0 0;line-height:1;margin-left:210px;;padding:5px 7px;"></span> </p> <div class="elements"> <label for="Password">Old Password:</label> <input type="password" id="old_password" name="old_password" required size="25" /> </div> <div class="elements"> <label for="Password">New Password:</label> <input type="password" id="update_password" name="update_password" required size="25" /> <br> <span style="font-size: 90%; color:#A4A4A4">(Must be 6 atleast characters)</span> </div> <div class="elements"> <label for="Password">Password Confirmation :</label> <input type="password" id="Password" name="password_confirmation" required size="25" /> </div> <div class="submit"> <input type="submit" value="Update" /> </div> </form> </body> </html> </div> <br> <?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/includes/menu.php"; include_once($path); $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/members/includes/footer.php"; include_once($path); ?>this is the backend file:
<?php $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/members/core/init.inc.php"; include_once($path); if (isset($_POST['old_password'], $_POST['update_password'], $_POST['password_confirmation'])){ $errors = array(); if ($_POST["update_password"] == $_POST["password_confirmation"]) { $errors[] = 'Passwords do not match.'; } if (empty($errors)){ function update_password($update_password){ $update_password = md5($update_password); $sql = "UPDATE `trades` SET `password` = '{$update_password}' WHERE `id` = '{$_SESSION['id']}' "; mysql_query($sql); echo mysql_error(); if(mysql_query($sql)){ $message = '<h4>Successful</h4>'; }else{ $message = '<h4>Fail</h4>'; } } } }else{ $message = '<h4 class="font1">Invalid Request</h4>'; echo mysql_error(); }Could someone help me out with what I have done wrong or missed, as this doesn't do anything.
Thanks.