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.
-
As many PDO discussions / tutorials exist, I have read tons and I am stumped. I just cannot figure out why mine isn't working. Any advice is very welcome as I have a very basic understanding of PHP (learning but have to finish this form) and I don't know where else to turn. Here is the code. I am just trying to secure 2 variables passed from the page before it - $_GET['CareerID'] and $_GET['Title']. Someone mentioned that it could be the vars are called out in the sql statement or bind, and someone else said it could be the $resultSet var. I thank you for taking the time to review. CODE (X'ing out passwords): $conn = new PDO('mysql:host=xxxx;dbname=xxxx', 'xxxx', 'xxxx'); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Leave column names as returned by the database driver $conn->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL); // Convert Empty string to NULL $conn->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING); $SQL = "SELECT * FROM careerapplicationpost,careerapplicationjobdescription WHERE careerapplicationpost.CareerApplicationPostID = '?' AND careerapplicationjobdescription.JobDescriptionTitle = '?'"; $sth = $conn->prepare($SQL); // binding parameters $sth->bindParam(':careerId', $_GET['CareerID'], PDO::PARAM_INT, 100); $sth->bindParam(':title', $_GET['Title'], PDO::PARAM_STR, 100); // executing statement $sth->execute(); $resultSet = $sth->fetchAll(); foreach ( $conn->query($SQL) as $row ) { //setup the postings echo "<h2>"; echo "<a href=\"/careers/view-career.php?CareerID=$row[CareerApplicationPostID]&Title=$row[JobDescription]\">$row[JobDescriptionDisplayTitle]</a><br />"; echo "</h2><hr />"; echo "<br />"; echo $row['Location']; echo ", "; echo $row['FullTimePartTime']; echo "<div class=\"postedon\">Posted on "; echo $row['PostedDate']; echo "</div>"; echo "<br />";echo "<br />"; echo "<strong>Summary:</strong> "; echo $row['JobDescriptionSummary']; echo "<br />";echo "<br />"; echo $row['JobDescriptionEdited']; echo "<div class=\"linebreak\"> </div>"; echo "<a href=\"/careers/files/DigiEmploymentApp.pdf\">Please fill out an application here.</a><br />"; echo "<div class=\"clear\"></div>"; echo "<hr />"; } if (!$row['CareerApplicationPostID']) { header("Location:index.php"); exit; } $conn = null; ?>
