php - Possible to send username that we use in session? -



php - Possible to send username that we use in session? -

i want send user id stored in session variable. when user submits form, database should receive info user submits , userid database. here have:

session_start(); if (!isset($_session['username'])); { header('location: index.php'); } <p>welcome, <b> echo $_session['username'];</b> if(isset($_post['submit'])) { $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('could not connect: ' . mysql_error()); } if(! get_magic_quotes_gpc() ) { $complaint = addslashes ($_post['complaint']); } else { $complaint = $_post['complaint']; }$sql = "insert employee ". "(complaint) ". "values('$complaint')"; mysql_select_db('sistempinjaman'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('could not come in data: ' . mysql_error()); } echo "you complaint sent. respon via email \n"; mysql_close($conn); }

can username sent submit form?

when want display data, table have:

| username | complaint |

what fields have in employee table? add together username field if not there , store username stored in session.

example:

$sql = "insert employee (username,complaint) values('".$_session['username']."','".$complaint."')";

php mysql

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -