Friday 15 February 2013

php - how to check whether old password entered is present or not in db -



php - how to check whether old password entered is present or not in db -

i m having login page user enters id , password.to reset password have check whether entered password nowadays or not whether matches id have entered.how validate it.i m unable validate it. if user enters password displays record updated. how validate it. here code

login.php

<label type="text" name="id" maxlength="50" size="20">id</label><br /> <input type="text" name="id" placeholder="id" class="input" size="20"/><br /></div> <div class="formitem"> <label type="text" name="uid" maxlength="50" size="20">password</label><br /> <input type="password" name="uid" placeholder="id" class="input" size="20"/><br /></div> <span class="field">(* required field)</span><br /><br /> <input type="submit" name="login1" value="login" class="button"><br /><br /><br /><br /> </form> </div> </body> </html> <?php $username = "root"; $password = ""; $hostname = "localhost"; $db = "abc"; //connection database $dbhandle = mysql_connect($hostname, $username, $password) or die("unable connect mysql"); mysql_select_db($db,$dbhandle) or die('cannot select db'); if(isset($_post['login1'])) { $id= $_post['id']; $uid= $_post['uid']; $query= "select * resume id='$id' , uid='$uid'"; $run= mysql_query($query); if(mysql_num_rows($run)>0){ echo "<script>window.open('resetp.php','_self')</script>"; } else { echo "<script>alert('login details incorrect!')</script>"; } } ?>

resetp.php

<label type="text" name="uid" maxlength="50" size="20">old password</label><br /> <input type="text" name="uid" placeholder="id" class="input" size="20"/><br /></div> <div class="formitem"> <label type="text" name="uid" maxlength="50" size="20">new password</label><br /> <input type="password" name="pass" placeholder="pass" class="input" size="20"/><br /></div> <div class="formitem"> <label type="text" name="cpas" maxlength="50" size="20">confirm password</label><br /> <input type="password" name="cpas" placeholder="" class="input" size="20"/><br /></div> <div class="formitem"> <input type="submit" name="login1" value="reset" class="formbutton"><br /><br /><br /><br /></div> </form> <?php $username = "root"; $password = ""; $hostname = "localhost"; $db = "resume1"; //connection database $dbhandle = mysql_connect($hostname, $username, $password) or die("unable connect mysql"); mysql_select_db($db,$dbhandle) or die('cannot select db'); if(isset($_post['login1'])) { $pass= $_post['pass']; $uid= $_post['uid']; $cpas=$_post['cpas']; $query = "update `resume` set uid='".$_post['pass']."' uid='".$_post['uid']."'"; $run = mysql_query($query); if($query) { echo "<script>alert('record updated')</script>"; } else { echo "<script>alert('no')</script>"; } } ?>

how can validated it

class="snippet-code-html lang-html prettyprint-override">try this: line <label type="text" name="uid" maxlength="50" size="20">new password</label><br /> should <label type="text" name="pass" maxlength="50" size="20">new password</label><br />

php mysql phpmyadmin

No comments:

Post a Comment