Search the Community
Showing results for tags 'php pdo'.
-
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.
-
hi, guys im actually trying to figure what is wrong here in my code as it var dumps in google chrome but not in firefox or opera, its quite confusing as php is a server side scripting language but is behaving like a client side script. it outputs fine in chrome but not in firefox as it gives "bool(false)" for the same script. can any one help me on this. the code to dbconfig is here: <?php session_start(); $host="localhost"; $dbName="project"; $dbUname="root"; $dbPass=""; try { $conn=new PDO("mysql: host=$host;dbname=$dbName;charset=utf8", $dbUname, $dbPass); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { $e->getMessage(); } require_once 'classes.inc.php'; $project= new projecteg($conn); the code to class's method is here: public function viewProtectedArea($uname,$pass) { $active=1; $stmth= $this->_db->prepare("select * from user where uname=:uname and pass=:pass and activated={$active}"); $stmth->bindparam(":uname",$uname); $stmth->bindparam(":pass",$pass); $stmth->execute(); return $stmth->fetch(PDO::FETCH_ASSOC); } and the code to login page is here: include_once 'dbconfig.inc.php'; if (isset($_POST['submit-login'])) { $uname= htmlentities($_POST['unamel']); $unamel= stripslashes($uname); $pass= htmlentities($_POST['passl']); $pass1= stripslashes($pass); $passl= md5($pass1); $user = $project->viewProtectedArea($unamel,$passl); var_dump($user); exit(); if ($user) { $_SESSION['id']=$user['user_id']; $_SESSION['fname']=$user['fname']; $_SESSION['lname']=$user['lname']; $_SESSION['uname']=$user['uname']; $_SESSION['email']=$user['email']; $_SESSION['phone']=$user['phone']; $_SESSION['app']=TRUE; $user_ok=TRUE; header("location: ../home.php?u={$_SESSION['uname']}"); } else { header("location: ../index.php?nosession"); } } please help me out.