www.webdeveloper.com
Results 1 to 6 of 6

Thread: Add a script that says RECORDS UPDATED

  1. #1
    Join Date
    Jul 2014
    Posts
    1

    Add a script that says RECORDS UPDATED

    Hello Everyone i have codes that updates the student records.

    PHP Code:
    $select_query="select student_id from student_information where student_id = '$student_id'";
    $result_set mysql_query($select_query,$link_id);

    if(
    $row mysql_fetch_array($result_set)){
        
    $flag="exists";
        
    header("location:Admin_Home.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());
        }
        
    $query "insert into student_information(student_id,student_password,first_name,last_name,registration_date,gender,date_of_birth,";
        
    $query .= "contact_no,grade,section,LRN,email1,email2,address,description,learner_id)";
        
    $query .= " values('$student_id','$student_password','$first_name','$last_name',now(),'$gender','$date_of_birth',";
        
    $query .= "'$contact_no','$grade','$section','$LRN','$email1','$email2','$address','$description','$learner_id')";
        
    $result mysql_query($query,$link_id);
        if(
    mysql_error() != null){
            die(
    mysql_error());
        }
        } 
    Now, my problem is to put a script that alerts that the "records has been updated" and from what part of this code be it inserted. Please advise.

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    788
    Well - what is the problem? You handled your first query with two options - one to go to another page to handle the 'found' record, the other to continue on and do an insert of a new record. Then you ran the insert query and checked for a failure properly, but you stopped there instead of putting out your "success" message or whatever you want to do.

    Why not re-display the original page again that you first obtained the student id from along with a message and then let them do the same process over again with a different id? If not that then simply do an echo of 'success' and exit.
    JG
    PS - If you're posting here you should be using:

    error_reporting(E_ALL | E_NOTICE);
    ini_set('display_errors', '1');


    at the top of ALL php code while you develop it!

  3. #3
    add header function on record insert, like you have added on the exits checking..

    Change the last if with this or add else on the last, its mean when data insert into database, return page with your message.
    PHP Code:
     if(mysql_error() != null){
            die(
    mysql_error());
        }
    else{    
    header("location:Admin_Home.php?update=true");  } 
    Put this code where you want to show the message.

    PHP Code:
    <?php 
    if($_REQUEST['update']=="true"){
    echo 
    "RECORDS UPDATED ";
    }
    else{}
    ?>

  4. #4
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    788
    The recommended method to use it either $_GET or $_POST and not the $_REQUEST. One should already know how his/her data is arriving and program accordingly. This code leaves the door open for hackers to supply data to your script in an unexpected way.
    JG
    PS - If you're posting here you should be using:

    error_reporting(E_ALL | E_NOTICE);
    ini_set('display_errors', '1');


    at the top of ALL php code while you develop it!

  5. #5
    I just provide a hint to him, if he is working on PHP, he knows better, any how thanks to inform..

  6. #6
    Join Date
    May 2014
    Posts
    26

    Add a script that says RECORDS UPDATED

    okay, This is so far what i got. this is the page handler where i update the records

    PHP Code:
    $query "UPDATE student_information SET first_name='$first_name',last_name='$last_name',";    
        
    $query .= "gender='$gender',date_of_birth='$date_of_birth',contact_no='$contact_no',grade='$grade',section='$section',";
        
    $query .= "LRN='$LRN',email1='$email1',email2='$email2',address='$address',description='$description'";      
        
    $query .= " WHERE student_id='$student_id'";      
        
    $result mysql_query($query$link_id);
        if(
    mysql_error() != null){
            die(
    mysql_error());
            }
            else{
                    
    $flag="success";
            }
            
    header("location:Admin_Edit_Student_Info.php?flag=$flag&student_id=$student_id");      
    ?> 
    What i want is after the records has been edited to update or as i clicked the update button. I will be redirected to Admin_home.php where i get the alert that the records are updated. Could this be possible?
    Please advise.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles