Using $_POST and $_GET

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nishmgopal
Forum Contributor
Posts: 101
Joined: Tue Mar 03, 2009 9:38 am

Using $_POST and $_GET

Post 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!
nishmgopal
Forum Contributor
Posts: 101
Joined: Tue Mar 03, 2009 9:38 am

Re: Using $_POST and $_GET

Post by nishmgopal »

Just a thought...do i need to use

require job.php or include job.php function
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: Using $_POST and $_GET

Post 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 { }.
Post Reply