Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8768687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:07:53+00:00 2026-06-13T17:07:53+00:00

1- I have inserted products in the table cart (and it works) 2- I

  • 0

1- I have inserted products in the table cart (and it works)
2- I identify if is a new or old customer(and it works)
3- I insert the new customer in the table customers or I update the new info of an existed customer. (and it works) I write here the code simplified.

I suppose that now I need to insert in the table cart, row customer_id, the id just created in the table customers (I mean the session id of table customers) How can I do that?

if(isset($_POST["continue"])){
    mysql_query("INSERT INTO customers (name)
    VALUES ('$_POST[name]')") 
    or die("error:".mysql_error());
    header("Location:step4.php");   

}else if (isset($_POST["update"])) {
    mysql_query("UPDATE customers 
                 SET name='$_POST[name]'
                 WHERE mail='$_SESSION[mail]'")
    or die("error:".mysql_error());
    header("Location:step4.php?updated");   
}

I tried and it does not work this:

mysql_query("INSERT INTO cart (customer_id)
             SELECT'$_SESSION['id']' 
             FROM customers")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:07:54+00:00Added an answer on June 13, 2026 at 5:07 pm

    Use the mysql_insert_id() as documented here: http://php.net/manual/en/function.mysql-insert-id.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the trouble to find is any new record is inserted in table.
I have inserted a code to display product attribute in view.phptml, which works fine.
I have created table and inserted values as below. create table mytable (id INT,
I have a ms sql table PRODUCTS. And it has three columns ID (int),NAME
I have a db table created like this CREATE TABLE products(id INT, name varchar(32),
I have a products table and each product have a category field (this is
I have a table which holds the products in a shopping basket (stowaway_orders) and
I have a table orderDetails that contains the products of an order productId color
I have to insert many product value records into an Oracle table. I get
I have the following table I have inserted Product B to it and it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.