0

I have this

session_start();
if ($_SESSION['email']&&$_SESSION['companyID'])
echo $_SESSION['email']."";
else
die("You must be logged in!");

and now im saving some data in database, and i want to save the companyID aswell by using createUser.php which contain these but its not saving the companyID

$userID=0;
$userRole=$_POST ["role"];
$userEmail = $_POST["userEmail"];
$userPassword = $_POST["userPassword"];
$companyID = $_POST[$_SESSION["companyID"]];

// insertion to user_details table

$sql = "INSERT INTO users (userID, email, password,companyID,roleID) VALUES 
                        ('$userID', '$userEmail', '$userPassword','$companyID','$userRole')";
6
  • $companyID = $_SESSION["companyID"]; change this Commented Feb 15, 2016 at 11:51
  • $companyID = $_POST[$_SESSION["companyID"]]; chnage this to either $companyID = $_SESSION["companyID"]; or $companyID = $_POST["companyID"]; Commented Feb 15, 2016 at 11:52
  • what you trying to get in the $companyID?? Commented Feb 15, 2016 at 11:52
  • $company_id is from session, so cannot come in POST request @Ms.Nehal Commented Feb 15, 2016 at 11:53
  • @PathikVejani, I thought he might be getting it form post as well, so I suggested both the options. As whichever option the user would be using he would use that one Commented Feb 15, 2016 at 11:54

1 Answer 1

1

Try replacing this:

$companyID = $_POST[$_SESSION["companyID"]];

For this:

$companyID = $_SESSION["companyID"];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.