Page 1 of 1

Using $_POST and $_GET

Posted: Sat Mar 07, 2009 9:11 am
by nishmgopal
Hey guys

I was wondering if you can help with one of my forms. I have a file calld job.php and the text field is called 'job':


<select name='job' id='job'>"


In another file I am using the sql statement

$getjob=$_POST['job'];
$query1 = "SELECT * FROM Job_Spec WHERE Project_Name ='$getjob'";

this file is called go.

this works fine.

But I am having trouble calling $getjob again in a different file (Called find10a.php). It doesnt return an error but just displays nothing. this is the code I am using:

Code: Select all

$getjob=$_POST['job'];
$query1 = "SELECT * FROM Job_Spec WHERE Project_Name ='$getjob'";
            
  $result1 = mysql_query($query1)
       or die ("Couldn't execute query.");
 
$colcnt = 0;
 
 
   while ($row = mysql_fetch_array($result1,MYSQL_ASSOC)) {
  {
     if (!$colcnt)
     {     
          $colcnt = 7;    
    }
 
   $colcnt--;{
      $Name1 = $row['Name'];
      $Java1 = $row['Java'];
      $Leadership1 = $row['Leadership'];
      $Communication1 = $row['Communication'];
      $Teamwork1 = $row ['Team_Work'];
      $Problem_Solving1 = $row['Problem_Solving'];
      }
}
I seem to think that its not working because, in the job.php file the action in the form is:

<form id='form2' method='post' action='go.php'>

But the find10a.php is not linked at all with the form and hence I cannot use $getjob?

Please can someone help!

Re: Using $_POST and $_GET

Posted: Sat Mar 07, 2009 9:12 am
by nishmgopal
Just a thought...do i need to use

require job.php or include job.php function

Re: Using $_POST and $_GET

Posted: Sat Mar 07, 2009 10:27 am
by watson516
Does the code you posted get the job passed via POST? If not, you can't go looking for it in POST. If you need it on multiple pages, you could use sessions.

As for that code you posted...

You need to secure your sql statement. You can't put anything POST straight into a sql statement.
Looks like you have an extra { in your while loop.
Not sure whats up with the second block of assignments but I dont think you need those two { }.