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

  • SEARCH
  • Home
  • 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 6696077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:17:54+00:00 2026-05-26T06:17:54+00:00

I can’t set a variable from a post array. I have a simple form

  • 0

I can’t set a variable from a post array.

I have a simple form with a hidden field in it:
<input name="sid" type="hidden" id="sid" value="<?=$sid?>">

This hidden field gets sent off to a second file (exec.php) where I have the following code:

$sid = $_POST['sid'];

For some reason, when trying to set $sid, it gets a NULL value. For haha’s, I ran the following:

foreach($_POST as $var => $value)
{
echo $var . ' : ' . $value . "<br>";
}

This provided a correct value of 1938 for sid. I’ve looked at this for 3 hours and can’t find what is happening. I expect something extremely stupid…any thoughts?


Here is the form on enter.php

    <form name="form1" method="post" action="exec.php">
     <input name="sid" type="hidden" id="sid" value="<? echo($sid); ?>">
     <input name="ticket_totals" type="hidden" id="ticket_totals" value="<?=$ticket_totals?>">
     <input name="emp" type="hidden" id="emp" value="<?=$emp?>">
     <input name="submit" type="submit" id="submit" value="Submit">
     <input type="submit" name="submit" id="submit" value="Close">
    </form>

Here is the POST output on exec.php:
type : Other
ticket_totals : 0
emp : 105
sid : 1939
submit : Submit


Okay – this was poor syntax on my part but now I’m curious as to why.

I left out quotation marks – the solution is as simple as this:
$sid = $_POST[“sid”]

Now it works like a champ.

Any takers on why? I’d guess there is a setting in the php.ini that requires the quotes. Strangely enough, I have other variables called from the POST array that i’m not using quotes for and they’re working fine…

  • 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-05-26T06:17:54+00:00Added an answer on May 26, 2026 at 6:17 am

    Use Console in FireBug to inspect the POST request to see what is the sid value that is being sent.

    If the sid value in request is ok, use var_dump($_POST["sid"]); to see the results on the server.

    EDIT: it’s considered good PHP style to use the quotes when accessing the associative array because quote-less keys are indistinguishable from constants:

    define('myVar',3);
    echo $array[myVar]; // retrieves $array[3], not $array['myVar'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can you have submenus with the top level set to checkable in WPF? I
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
Can I call a java class method from inside a flash movie?
Can we have two main() functions in a C++ program?
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) I have a Rails
Can I invoke an option on a COM Add-in from a VBA macro in
I have a bunch of posts stored in text files formatted in yaml/textile (from
Does anyone know how can I replace this 2 symbol below from the string
Can we add multiple rows in the database table from one JSF page in

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.