Undefined index: learner_id

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hanspeare
    New Member
    • May 2014
    • 20

    Undefined index: learner_id

    I have made this codes that registers the students using their learner id. And of course i wanted to make sure that there will be no duplication of learner id as students registered.Thes e are my codes.
    Code:
    	/*
    		This block is used to check whether the student_id already exists in database. 
    	*/
    	$select_query="select student_id from student_information where learner_id = '$learner_id'";
    	$result_set = mysql_query($select_query,$link_id);
    	
    	if($row = mysql_fetch_array($result_set)){
    		$flag="exists";
    		header("location:Student_login.php?flag=$flag&student_id=$student_id");
    		die();
    	}
    	else{
    		/*
    			This block is used to insert the learners record in database 
    			if the student_id is not yet registered in the database. 
    		*/
    		mysql_query("SET AUTOCOMMIT = 0 ");
    		if(mysql_error() != null){
    			die(mysql_error());
    		}
    Everytime there is a duplication of learner id by using this code on the other page.
    Code:
    >This Learner Id( <?php $_GET['learner_id'] ?> ) already exists. Please try again with another Learner Id.</td>
    The log in page give me notice

    This Learner Id(
    Notice: Undefined index: learner_id in C:\xampp\htdocs \a\Student_logi n.php on line 61
    ) already exists. Please try again with another Learner Id.

    How do i fix this one. Please advise.
  • Bharat383
    New Member
    • Aug 2011
    • 93

    #2
    Please check your table's learner_id collumn is set as unique or primary key then you have to set as not null.

    Comment

    • hanspeare
      New Member
      • May 2014
      • 20

      #3
      @Bharat383

      Yes already did.

      Comment

      • Bharat383
        New Member
        • Aug 2011
        • 93

        #4
        would you put here your table structure.

        Comment

        • Rabbit
          Recognized Expert MVP
          • Jan 2007
          • 12517

          #5
          Actually, the error is saying that your $_GET array does not have anything called learner_id.

          Comment

          • omerbutt
            Contributor
            • Nov 2006
            • 638

            #6
            the page where you are trrying to show the message the expression
            Code:
            <?php $_GET['learner_id']?>
            the page cannot detect any set index named learner_id in the $_GET array , verify that when you land or access that page are you sending the learner_id via GET, either you are using form , or using the query string please show the complete code.
            regards,
            Omer Aslam

            Comment

            Working...