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
Post a Comment