-4
$jobid=$_GET['jobid'];
if ($loggedin) 
    {
  $job_sql="SELECT job.*, members.* from job inner join members WHERE job.jobid = '$jobid'";
     if(isset($_POST["submit"]))
       {
         $sql="INSERT INTO applied(user,jobid) VALUES('$user','$jobid')";
               $result=mysql_query($sql);
                  if($result)
                    {
                  header('Location: submit.php');
                    } else
                    {
                    echo "Failure!";
                    }
        }
     };

'Members' and 'job' are 2 tables and there is a form which have submit button whose form action is the same page. so when clicked on submit it should search for post submit and submit the form, But when Clicked on submit, I'm getting an error

(Notice: Undefined index) in line number 12 ($jobid=$_GET['jobid'];)

jean
  • 4,159
  • 4
  • 31
  • 52
Naren
  • 5
  • 4

2 Answers2

1

Use $_POST not $_GET

$jobid=$_POST['jobid'];

A $_POST parameter comes from a form submission. A $_GET parameter comes from the URL string like so index.php?jobid=1234. If I am incorrect, you will need to post your HTML form so we can see what else could be wrong.

Your form action needs to look like this when it is submitted for the $_GET to work:

<form action="index.php?jobid=123" method="post">...</form>

or, it could also look like this:

<form action="index.php" method="get"><input type="hidden" name="jobid" value="123">...</form>
Clay
  • 4,700
  • 3
  • 33
  • 49
  • No, the $_get parameter is used to fetch information in the table using jobid and yes it goes like index.php?jobid=1 – Naren Dec 29 '15 at 11:28
  • Please post the HTML of your form. Specifically the action and method attribute of the `
    ` tag.
    – Clay Dec 29 '15 at 11:31
  • View the source of the HTML generated by your PHP to verify the jobid is there. – Clay Dec 29 '15 at 11:34
1

Declare your variables. Or use isset() to check if they are declared before referencing them, as in:

$jobid= isset($_GET['jobid']) ? $_GET['jobid'] : '';

Please post your form code you use to post this variable or Let me know the form method to identify whether it is $_GET or $_POST