mysql - PHP on submit the variable 'passkey' drops stopping UPDATE to database -
when user selects account activation link taken webpage welcome message, , request them update account details (set own password etc). currently, welcome request works fine, code recognises passkey (which displayed in url code) , print users name. however, problem seems come when user selects 'submit' button update details in form. variable of passkey seems drop, on submission details arent being stored database though php message tells me is.
this code:
<?php session_start(); include "includes/header.php"; include "includes/connect.php"; ?> <link rel="stylesheet" type="text/css" href="css/login.css"> <div class="jumbotron"> <h1>new users</h1> <p>register details</p> </div> <?php $_session['passkey']=$passkey; $passkey=$_get['passkey']; $sql1="select firstname users confirm_code ='$passkey'"; $result1=mysqli_query($conn, $sql1); $count = mysqli_num_rows($result1); $updateactive="1"; if ($count==1){ $activequery = mysqli_query($conn, "update users set activate='$updateactive' confirm_code='$passkey'"); if ($activequery) { $row = mysqli_fetch_row($result1); echo "welcome " .$row[0]. " please update details:"; } else die('invalid query: ' . mysqli_error()); }else echo "wrong confirmation code"; ?> <div class="container"> <form class="form-activate" role="form" action="emailactivation.php" method="post"> <h2 class="form-signin-heading">register details</h2> <p>*all fields required</p> <input class="form-control" type="text" placeholder="current password*" name="current_password" maxlength = "30" required autofocus> <input class="form-control" type="text" placeholder="new password*" name="new_password" maxlength = "30" required autofocus> <input class="form-control" type="text" placeholder="confirm new password*" name="confirmnew_password" maxlength = "30" required autofocus> <select class="form-control" name="department_category"> <option value="0">department category*</option> <option value="1">administrative services</option> <option value="3">business development</option> <option value="4">health & safety</option> <option value="5">finance & accounting</option> <option value="6">hr</option> <option value="7">it</option> <option value="8">legal</option> <option value="9">research & development</option> <option value="10">sales</option> <option value="11">science</option> </select> <select class="form-control" name="role"> <option value="0">role*</option> <option value="1">director</option> <option value="3">manager</option> <option value="4">graduate</option> <option value="5">intern</option> <option value="6">assistant</option> <option value="8">head of department</option> </select> <button class="btn btn-lg btn-primary btn-block" type="submit" name="submitdetails">update details</button> </form> </div> <?php if(isset($_post['submitdetails'])){ $rcpwd= trim($_post['current_password']); $usrnewpwd= trim($_post['new_password']); $usrconfirm_newpwd= trim($_post['confirm_newpassword']); $usrdepartment=trim($_post['department_category']); $usrrole=trim($_post['role']); $updateactivationkey="2"; $q2 = "select * users password='$rcpwd' limit 1;"; $resultset2 = mysqli_query($conn,$q2); $rows2 = mysqli_num_rows($resultset2); if ($rows2==1){ echo 'we update details'; //if fields have data if (!empty($_post)){ if($usrdepartment!=0){ if($usrrole!=0){ echo"hello1"; // $updatequery = mysqli_query($conn, "update users set password='$usrnewpwd', departmentid='$usrdepartment', roleid='$usrrole' firstname='$row[0]';"); $updatequery = mysqli_query($conn, "update users set activate='$updateactivationkey' confirm_code='$passkey';"); / if ($updatequery) { echo 'details have been added'; }else die('invalid query: ' . mysqli_error()); } else echo 'warning 1'; } else echo 'warning2'; } else echo 'warning3'; } else echo'<div class="login-error">please fill in fields</div>'; } ?> <?php require "footer.php"; ?>
id appreciate advice on matter can update results according user. in advance.
add hidden field in form as
<input type="hidden" name="passkey" value = "<?php echo $passkey ;?>">
so once submit form can retrieve data as
$passkey = $_post["passkey"]
Comments
Post a Comment