Jump to content

Capturing Username Session to Database


jassikundi

Recommended Posts

Hi everyone, I've created a login system when users login they have the option to submit an online quote. I've created the database to capture the data, everything works fine apart from capturing the username of the person logged in.

 

My quote page uses this method to retrieve the username of the person logged in and displays it fine.

 

<?

include("../include/session.php");

?>

 

<h1>User Account Edit : <? echo $session->username ?></h1>

 

This is displaying the username of the person logged in: I'm using the post method to then process the quote form. How would I capture this and send it to my database? At the moment I'm trying the following:

 

//Get username of person logged in

$session->username=$_POST['username'];

 

//Send username to database

mysql_query("INSERT INTO `contracts` VALUES (''$username')") ;

 

Can someone advise me what I'm doing wrong? Also i'm not sure if I had to include include("../include/session.php"); to the process page but it gave me an error so im guessing its not required as it stops any data from being stored to the database.

 

Regards

Jassi

 

Link to comment
https://forums.phpfreaks.com/topic/89915-capturing-username-session-to-database/
Share on other sites

Hi Thorpe can you elaborate any further what would I need to do inorder for me to capture the data and post it? I dont quite understand what your saying by "you don't define the $username variable your using within your query".

 

Thanks for the help.

;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.