Jump to content


New Members
  • Posts

  • Joined

  • Last visited

uumer93's Achievements


Newbie (1/5)




Community Answers

  1. Thank you for your help, I've tested so much tips and the solution was hidded inside the stored user id in SESSION so what I've did is to change this variable $_SESSION['username'] = $result->action_code; and show it inside my input's value. and it works perfectly I did a lot of tests and it is done. Thank you guys for all your help. its been a pleasure to learn from you devs. Have a good week ♥
  2. I think the problem is from the function or inside the controller : CentersController.php <?php public function authCenter(){ if (isset($_POST['submit'])) { $data = array( 'agency_user'=>$_POST['user'], 'action_code'=>$_POST['password'] ); $result = Center::loginC($data); if ($result->agency_user === $_POST['user'] && $result->action_code === $_POST['password']) { $_SESSION['logged'] = true; $_SESSION['username'] = $result->agency_user; Redirect::to('formulaire'); }else{ Session::set('error','Utilisateur ou mot de passe est incorrect'); Redirect::to('login'); } } } ?> And Center.php <?php static public function loginC($data){ $agency_user = $data['agency_user']; try { $query = 'SELECT * FROM agencies_data WHERE agency_user=:agency_user'; $stmt = DB::connect()->prepare($query); $stmt->execute(array(":agency_user"=>$agency_user)); $usuario = $stmt->fetch(PDO::FETCH_OBJ); return $usuario; if ($stmt->execute()) { return 'ok'; } } catch (PDOException $e) { echo 'Erreur '.$e->getMessage(); } } ?> I've tried to add $password = $data['password'] as a var and then insert it inside array located in Center.php but still got an empty Array in formulaire.php page.
  3. I've tried this and the result is an empty array => array(0) { } to explain more, The formulaire page is a page you cannot use if you are not connected and it is not a register page. So the main idea here is let the user connect using the login form Then send the user to a new page that contains a form to let them insert data that will be sent via api to client's server and this is not the problem The problem is impossible to store the value entred inside password field that is located in login.php page and show it as a value inside oid field located in formulaire.php page And the array is 0 Why ?
  4. Thank you, I've tried to print data and nothing is showed I've used if submit is clicked then print data as value and as a result I got a hidden input. And I 've try to show it directly without if statement I got this warning result => Undefinned array key.
  5. Hello Guys! I'm sorry for being a bit late, it's just because of exams that's why I cannot connect to keep learning more from you as I can see in your comment too much infos to save. I can't tell you how much I'm happy for all of this content you have posted, Thank you for your help I've noticed a lot of things here which means I must keep learning and try my best to understand more about php. I've tried all of your codes and nothing has work for me which absolutely means the problem is from me that's why I need your help in terms of explaining what mistakes I did till now. I will post full content to explain you more about my issue. I've analyzed all your codes and mine too. and I guess it can be made without the use of database actualy, if the user is logged in so I will just take his password which is a text code named "pasword" and insert it inside the input's value => BUT IT DIDN'T WORK WITH ME (-_-) as you can see guys below I want to send a user after he logged in to another page which is called "formulaire" and recuperate the values there. You can notice there is no extension after the name's file because I'm working with .htaccess file and a redirection function so everyting works fine for me. login.php <?php if (isset($_POST['submit'])) { $data = new CentersController(); $data->authCenter(); //this method is to let the user login after pressing the submit btn. and it works fine. } //This include shows alerts in case the user type a wrong username or password. include('./views/includes/alerts.php'); ?> <section class="login-dark"> <form method="post" action="formulaire"> <div class="illustration"><i class="icon ion-ios-locked-outline"></i></div> <div class="mb-3"> <input class="form-control" type="text" name="user" placeholder="User"> </div> <div class="mb-3"> <?php //This a code as a text. I've just named it as "password" so it's not a password type in case you tought I'm wrong in input's type. ?> <input class="form-control" type="text" name="password" placeholder="Action code"> </div> <div class="mb-3"> <button class="btn btn-primary d-block w-100" type="submit" name="submit">LOGIN</button> </div> </form> </section> And here is the other file: formulaire.php <?php //You can notice here there is no php code, because after testing all of your codes so I just removed everything to give you a clean view. ?> <div class="container" style="margin-top: 12px;"> <div style="background: #f8f8f8;padding: 36px;border-radius: 38px;"> <div class="row justify-content-center align-items-center"> <div class="col-8"> <form method="post" action="sendingData"> <h2 class="text-center" style="padding: 24px;"><strong>Formulaire d'insértion.</strong></h2> <div class="mb-3"> <select class="form-select" required name="civilite"> <optgroup label="Civilité"> <option value="1" selected="">Monsieur</option> <option value="2">Madame</option> <option value="3">Mademoiselle</option> </optgroup> </select> </div> <div class="row"> <div class="col"> <div class="mb-3"> <input class="form-control" type="text" name="nom" placeholder="Nom" required=""></div> </div> <div class="col"> <div class="mb-3"> <input class="form-control" type="text" name="prenom" placeholder="Prénom" required=""></div> </div> </div> <div class="mb-3"> <input class="form-control" type="text" name="telephone" placeholder="Téléphone" required=""></div> <div class="mb-3"> <input class="form-control" type="email" name="email" placeholder="Email" required></div> <div class="mb-3"> <input class="form-control" type="text" name="codepostal" placeholder="Code postal" required></div> <div class="mb-3"> <select class="form-select" required name="imposition"> <optgroup label="Imposition"> <option value="1" selected="">Non imposable</option> <option value="2">Moins de 2000€</option> <option value="3">Moins de 2500€</option> <option value="4">Entre 2500€ et 3000€</option> <option value="5">Entre 3000€ et 5000€</option> <option value="6">Entre 5000€ et 10000 €</option> <option value="7">Plus de 10000€</option> </optgroup> </select> </div> <div class="mb-3"> <?php //So here is the problem as I told you before, I can't show the text typed in login password field => inside this field's value ?> <input class="form-control" type="text" name="oid" value="" > </div> <div class="d-lg-flex justify-content-lg-center align-items-lg-center mb-3"> <button class="btn btn-success d-block w-100" type="submit" style="margin-right: 10px;margin-left: 10px;">ADD</button> <a href="<?php echo BASE_URL; ?>clogout" class="btn btn-light d-block w-100" style="margin-right: 10px;margin-left: 10px;">LOGOUT</a> </div> </form> </div> <div class="col-4"> <div style="background: url(&quot;assets/img/nature.jpg&quot;) center / cover no-repeat;height: 476px;border-radius: 30px;"></div> </div> </div> </div> </div> Thank you guys for your time, I appreciate all of your answers and your corrections.
  6. Hi guys! I've tried to insert data inside an input's value but the input goes like it is hidden, When I inspect the page it shows that there is no input inside my form. I've tried to move the code to the top of page but nothing is changed always a hidden input while it is not hidden at all as you can see below: <div class="mb-3"> <?php //Checking if submit button is clicked if (isset($_POST['submit'])) { //database cn $db = new PDO("mysql:host=localhost;dbname=centrify","root",""); $username = $_POST['user']; $stmt = $db->prepare("SELECT * FROM agencies_data WHERE agency_user = ".$username.""); $stmt->execute(); ?> <input class="form-control" type="text" name="oid" value="<?php while($item = $stmt->fetch()) { echo $item['agency_user']; } ?>"> <?php } ?> </div> I've tested a lot of placements but it doesnt work for me.
  • 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.