How can I pull user details if they're logged in username matched a username in another table on Drupal? -


i have attemped following code:

<?php  session_start();  // connects database $mysqli = new mysqli("localhost", "root", "");  $query = "select first_name, last_name, balance customers username = '".$_session['name']."'"; if($result = $mysqli->query($query)) { while($row = $result->fetch_assoc()) { echo "<div align=\"center\">"; echo "<br />your <b><i>profile</i></b> follows:<br />"; echo "<b>first name:</b> ". $row['first_name']; echo "<br /><b>last name:</b> ".$row['last_name']; echo "<br /><b>balance:</b> ".$row['balance']; echo "</div>";    } $result->free(); } else { echo "no results found"; } 

i following error:

notice: session had been started - ignoring session_start() in   include_once() (line 2 of     c:\wamp\www\drupalnew\sites\all\modules\new_balance\balance_module.module).   notice: undefined index: name in include_once() (line 7 of   c:\wamp\www\drupalnew\sites\all\modules\new_balance\balance_module.module).   

i want give details user logged in drupal 7 site.

just use:

function your_function() {   global $user;    $username = $user->name; // instead of $_session['name']    // ... query } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -