php - Store variable in Session -
i want store user_level mysql db of user submits form in $_session
code this:
<form id='login' action='<?php echo $fgmembersite->getselfscript(); ?>' method='post' accept-charset='utf-8'> <fieldset > <?php if(isset($_post['submitted'])) { session_start(); if($fgmembersite->login()) { $mysqli = new mysqli('host', 'name', 'psw', 'db'); if ($result = $mysqli->query("select user_level users username='$username'")) { $_session['user_level'] = $result; } $fgmembersite->redirecttourl("loginhome.php"); } } ?> <legend>login</legend> <input type='hidden' name='submitted' id='submitted' value='1'/> <div class='short_explanation'>* benötigte felder</div> <div><span class='error'><?php echo $fgmembersite->geterrormessage(); ?></span></div> <div class='container'> <label for='username' >benutzername*:</label><br/> <input type='text' name='username' id='username' value='<?php echo $fgmembersite->safedisplay('username') ?>' maxlength="50" /><br/> <span id='login_username_errorloc' class='error'></span> </div>
now checked on site, got redirected print_r($_session);
, result:
[user_level] => mysqli_result object ( [current_field] => [field_count] => [lengths] => [num_rows] => [type] => )
can explain me happens there? or went wrong?
this not fix issue session should started @ utmost top of script.
<?php if (!isset($_session)) { session_start(); } // ... other code ...
there issue query. should use like:
$conn = new mysqli('host', 'username', 'password', 'database'); $stmt = $conn->prepare("select * table id = ?"); $stmt->bind_param("s", $editid); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); print_r($row);
Comments
Post a Comment