php - Framework7 not passing URL variable to next page -
i can't framework7 use url variable ?username=user1
on next page.
it generated , assigned link on page 1 doesn't used in either sql query or echo statements on page 2.
page 1 sets variable in hyperlink with;
profile.php?username=<?php echo htmlentities($row['username'], ent_quotes, 'utf-8'); ?>
page 2 'gets' variable using;
<?php $username = (isset($_get['username']))? trim(strip_tags($_get['username'])) : ""; ?>
framework7 web application framework - www.idangero.us/framework7/.
edited add full source of profile.php use variable.
<?php // first execute our common code connection database , start session require("common.php"); // @ top of page check see whether user logged in or not if(empty($_session['user'])) { // if not, redirect them login page. header("location: index.php"); // remember die statement absolutely critical. without it, // people can view members-only content without logging in. die("redirecting index.php"); } // below point in file secured login system // can retrieve list of members database using select query. // in case not have clause because want select // of rows database table. $query = " select id, username, email users username = '$username' "; try { // these 2 statements run query against database table. $stmt = $db->prepare($query); $stmt->execute(); } catch(pdoexception $ex) { // note: on production website, should not output $ex->getmessage(). // may provide attacker helpful information code. die("failed run query: " . $ex->getmessage()); } // finally, can retrieve of found rows array using fetchall $rows = $stmt->fetchall(); ?> <?php include('header.php') ?> <div class="pages navbar-through toolbar-through"> <div class="page" data-page="profile"> <div class="page-content"> <div class="content-block"> <div class="content-block-inner"> <?php print_r($_get); ?> <p>profile content go here - <?php echo '&username'; ?></p> <?php foreach($rows $row): ?> <div>username: <?php echo $row['username'] ?></div> <div>location: <?php echo $row['email'] ?></div> <?php endforeach; ?> <a href="private.php">go back</a><br /> </div> </div> </div> </div> </div> <?php include('footer.php') ?>
i have printed $get
variables , can see variable value passed - not being used in query reason.
you have not assigned $username
variable should use this:
<?php // first execute our common code connection database , start session require("common.php"); // @ top of page check see whether user logged in or not if(empty($_session['user'])) { // if not, redirect them login page. header("location: index.php"); // remember die statement absolutely critical. without it, // people can view members-only content without logging in. die("redirecting index.php"); } // below point in file secured login system // can retrieve list of members database using select query. // in case not have clause because want select // of rows database table. $username = (isset($_get['username']))? trim(strip_tags($_get['username'])) : ""; $query = " select id, username, email users username = '$username' "; try { // these 2 statements run query against database table. $stmt = $db->prepare($query); $stmt->execute(); } catch(pdoexception $ex) { // note: on production website, should not output $ex->getmessage(). // may provide attacker helpful information code. die("failed run query: " . $ex->getmessage()); } // finally, can retrieve of found rows array using fetchall $rows = $stmt->fetchall(); ?> <?php include('header.php') ?> <div class="pages navbar-through toolbar-through"> <div class="page" data-page="profile"> <div class="page-content"> <div class="content-block"> <div class="content-block-inner"> <?php print_r($_get); ?> <p>profile content go here - <?php echo $username; ?></p> <?php foreach($rows $row): ?> <div>username: <?php echo $row['username'] ?></div> <div>location: <?php echo $row['email'] ?></div> <?php endforeach; ?> <a href="private.php">go back</a><br /> </div> </div> </div> </div> </div> <?php include('footer.php') ?>
you should escape input's prior going db
Comments
Post a Comment