$_POST question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JimS
    New Member
    • Jul 2006
    • 4

    $_POST question

    In the first if statement am I properly checking for a post variable? Also, is the post variable's name the same as the input name?

    Code:
    if(isset($_POST('job_select')))
    {
    	$job_name=$_POST('job_select');
    	
    	$result=mysql_query("SELECT DISTINCT labor_code FROM oats_jobs_users_laborCode where user='$user_name' and job_name='$job_name' order by job_name;"); 
    
    	if($result)
    	{
    		echo "<select name=\"laborcode\" onchange=\"timecard.submit()\" > <option default=\"default\" value=\"\">Choose One</option>"; 
    		while($row=mysql_fetch_row($result))
    		{ 
    			echo "<option value=\"$row[0]\">$row[0]</option>";
    		} 
    			echo "</select>";
    }
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    isset is fine to check the existence of a $_POST variable. However, this variable could be blank. So you'll have to check its contents.

    You can assign the $_POST variable to any PHP variable name you like.

    Ronald :cool:

    Comment

    • JimS
      New Member
      • Jul 2006
      • 4

      #3
      If the variable is set it cannot be blank (response from drop down box)

      Is it a problem that I am calling it via a function?

      Comment

      • iam_clint
        Recognized Expert Top Contributor
        • Jul 2006
        • 1207

        #4
        this might not work take a close look
        Code:
        if(isset($_POST('job_select')))
        check this
        Code:
        if(isset($_POST['job_select']))
        $job_name=$_POST['job_select'];

        Comment

        • rkagrawal
          New Member
          • Aug 2006
          • 13

          #5
          $_POST is a variable and not a function .
          You should use $_POST[] rather than $_POST() .

          The same goes with $_GET , $_FILES etc etc.


          Rahul Agrawal
          Developer
          Web2003 Corporation
          www.web2003corp .com

          Comment

          Working...