phpnewbie123 phpnewbie123 - 11 months ago 45
PHP Question

Click the button, save the data and go to next php page

I don't know what is the problem. After i click the button, it only the data into database but will not go to next php page. Help me find out what is problems. Thank you.

$AddMCQ = "INSERT INTO tblmc(Name,FromDate,ToDate,Reason) VALUES('".strtoupper($_POST['txtName'])."','".$_POST['txtFrom']."','".$_POST['txtTo']."','".strtoupper($_POST['txtReason'])."')";
$AddMCResult = mysql_query($AddMCQ,$link);
header('Location: mcreport.php');

echo "<script>alert('Record Added.');</script>";

<input type="submit" name="btnSubmit" id="btnSubmit" value="Submit"/>

Answer Source

Try this


        $AddMCQ = "INSERT INTO tblmc(Name,FromDate,ToDate,Reason) VALUES('$txtName','$txtFrom','$txtTo','$txtReason')";
        $AddMCResult = mysql_query($AddMCQ,$link);
               echo "<script language=\"JavaScript\">\n";
        echo "alert('Record Added.');\n";
        echo "window.location='mcreport.php'";
        echo "</script>";