Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2011
    Posts
    95
    Thanks
    13
    Thanked 1 Time in 1 Post

    insert data from one table to another

    Hello.
    I insert some data into a sales table when a user make a transaction, and i want to add the userid in that table. How can i do that? i tried some session stuff but i found it a bit complicated.

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,546
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Uh... rather vague question. How do you store the users data? Sessions seem the best/only real way to do it. I assume you store the user's ID in a session value somehow, hashed or not?

  • #3
    New Coder
    Join Date
    Apr 2011
    Posts
    95
    Thanks
    13
    Thanked 1 Time in 1 Post
    atm i am trying to insert the username instead of the id.


    i display the current username through a session
    PHP Code:
    Welcome <?php echo $_SESSION['MM_Username']?>
    I try this but it inserts just a blank username.

    PHP Code:
    $MM_Username $_SESSION[MM_Username]; 
    PHP Code:
    $sql="INSERT INTO sales(address,username) VALUES
    ('$_POST[address]','$MM_Username')"

    Last edited by garevn; 05-23-2011 at 10:13 PM.

  • #4
    New Coder
    Join Date
    Apr 2011
    Posts
    95
    Thanks
    13
    Thanked 1 Time in 1 Post
    ok it work now guys i didnt change comething i just close and reopen the browser, probably a bug. Tnx for help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •