1

I've tried to use ob_start(); and exit(); ,both are not working, please advise, thank you very much

<?php 
    ob_start();

    // connect to the database
    include('connect-db.php');

    // check if the form has been submitted.
    // If it has, start to process the form and save it to the database
    // once saved, redirect back to the view page
    if (isset($_POST["submit"]))
    {
        foreach ($_POST['patientid'] as $index => $patientid)
        {
            $id = mysql_real_escape_string($_POST['id'][$index]);
            $data1 = mysql_real_escape_string($patientid);
            $data2 = mysql_real_escape_string($_POST['vaccineid'][$index]);
            $data3 = mysql_real_escape_string($_POST['vaccinename1'][$index]);
            $data4 = mysql_real_escape_string($_POST['vaccinename2'][$index]);
            $data5 = mysql_real_escape_string($_POST['vaccinename3'][$index]);
            $data6 = mysql_real_escape_string($_POST['totalnoofinjection'][$index]);
            $data7 = mysql_real_escape_string($_POST['nthinjection'][$index]);
            $data8 = mysql_real_escape_string($_POST['date'][$index]);
            $data9 = mysql_real_escape_string($_POST['nextdate'][$index]);
            $data10 = mysql_real_escape_string($_POST['skip'][$index]);
            $data11 = mysql_real_escape_string($_POST['language'][$index]);         

            mysql_query("UPDATE patientvaccinedetail SET patientid = '$data1',
                vaccineid = '$data2', vaccinename1 = '$data3',
                vaccinename2 = '$data4', vaccinename3 = '$data5',
                totalnoofinjection = '$data6', nthinjection = '$data7',
                date = '$data8', nextdate = '$data9', skip = '$data10', 
                language = '$data11'
                WHERE id=$id") or die(mysql_error());

            header("Location: start.php");
            exit;
        }
    }

Just updated and still cant't redirect to another pages

epiphany
  • 756
  • 1
  • 11
  • 29

2 Answers2

3

You are missing semi colon after exit

Corrected code:

exit;

Pupil
  • 23,834
  • 6
  • 44
  • 66
1

use ob_end_clean(); before the header call and use exit; instead of exit

try like below

ob_end_clean();
 header("Location: start.php");
exit;
Narayan
  • 1,670
  • 1
  • 19
  • 37
  • will the exit actually be executed though since the header line redirects to a different page? – Ortund Jun 22 '17 at 07:45
  • Cannot modify header information - headers already sent by (output started at C:\inetpub\wwwroot\June21\displaypatient.php:58) in C:\inetpub\wwwroot\June21\displaypatient.php on line 136 – epiphany Jun 22 '17 at 09:24
  • @tam you have echo anything in db connection file – Narayan Jun 22 '17 at 09:25