I can't handle php mysql login page -


i trying make change password users. cant manage it. whatever tried, returns me problem alert wrote. can suggest anything? trying fix hours.

the below form code;

                <form action="change_s_pwd.php" method="post" class='form-horizontal form-validate' id="bb">                                     <div class="control-group">                                         kullanıcı adı :                                          <div class="controls">                                              <input type="text" name="user" placeholder="your login id" data-rule-required="true" data-rule-minlength="4"/>                                             </p>                                         </div>                                      <div class="control-group">                                         <p>secure id :                                      </p>                                         <div class="controls">  <input type="text" name="sec_id"  class="input-xlarge" placeholder="your secure id" data-rule-required="true" data-rule-minlength="6"></div>                                     </div>                                     <div class="control-group">                                         password :                                       <div class="controls">                                         <input type="password" name="pass" id="pass" class="input-xlarge" data-rule-required="true" data-rule-minlength="6" placeholder="your new passowrd">                                      </div>                                                         </div>                                     <div class="control-group">                                         confirm password :                                       <div class="controls">                                         <input type="password" name="confirmfield" id="confirmfield" class="input-xlarge" data-rule-equalto="#pass" data-rule-required="true" data-rule-minlength="6" placeholder="confirm new passowrd">                                       </div>                                     </div>                                     <div class="control-group">                                       <div class="controls"></div>                                     </div>                 </div>                  <div class="form-actions">                                         <input type="submit" class="btn btn-primary" value="submit">                                         <button type="button" class="btn">cancel</button>                                     </div>                                 </form> 

and below submit code;

<?php include 'index.php'; include '../include/db_conn.php'; if (isset($_post['sec_id']) && isset($_post['pass']) && isset($_session['user_data'])) {     $sec_id       = rtrim($_post['sec_id']);     $pass         = rtrim($_post['pass']);     $user_id_auth = $_session['user_data'];     $sql          = "select * login_auth sec_id='$sec_id'";     $result       = mysqli_query($con, $sql);     $count        = mysqli_num_rows($result);     if ($count == 1) {         mysqli_query($con, "update login set pass='$pass' user='$user_id_auth'");         echo "<html><head><script>alert(password changed succesfully ');</script></head></html>";         echo "<meta http-equiv='refresh' content='0; url=index.php'>";     } else {         echo "<html><head><script>alert('there has been problem while changing password');</script></head></html>";         echo "<meta http-equiv='refresh' content='0; url=index.php'>";     } } else {     echo "<html><head><script>alert('there has been problem while changing password');</script></head></html>";     echo "<meta http-equiv='refresh' content='0; url=index.php'>"; } ?> <center> <img src="loading.gif"> </center> 

i glad if guys can me. in advance

you making check on $count variable in contains number of rows returns $result (result set)and maybe equal 0 if mysqli_query function return no result (empty query result ...) must check first result set ($result) $count ... in case sure if mysqli_query returns result or not .. below code ... :

// check connection if (mysqli_connect_errno())   {   echo "failed connect mysql: " . mysqli_connect_error();   }   $sql          = "select * login_auth sec_id='$sec_id'";  if ($result=mysqli_query($con,$sql))   {   // return number of rows in result set   $rowcount=mysqli_num_rows($result);   printf("result set has %d rows.\n",$rowcount);   // free result set   mysqli_free_result($result);   }    mysqli_close($con); 

also not write html code string php ... lead many errors , hard debug problem ... use header function in php or redirect redirect page want in case want ...


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -