how to pass data from one html page to second in php?

后端 未结 6 1597
南笙
南笙 2021-01-23 15:05

I have created a page for updation of record. I want to pass the id of student from one page to another. I am trying to send it through window.location but it is not working. In

6条回答
  •  面向向阳花
    2021-01-23 15:25

    If you already have a form and wanna post that to an update script, you could just add the student id as an hidden form element example:

    
    

    Else if you want to redirect from another page to the update page, with a student id, the best way will probably be a $_GET variable. So the URL would look something like this: http://domain.com/update.php?student_id=1

    And then your update.php will include a simple check like this.

    if(!empty($_GET['student_id'])) {
        $student_id = $_GET['student_id'];
        // Ready to update
    } else {
        // Throw 404 error, or redirect to an create page
    }
    

提交回复
热议问题