This question already has an answer here:
The following php script is used by me to transfer the data in one database table to another database table and then delete the entry from the initial table!
<?php
require("../../db/db.php"); //contains database connection
if( isset($_GET['del']) )
{
$id = $_GET['del'];
$sql1="INSERT INTO complete (`OrderNo.`,`NIC`,`DP`,`Address`,`DPTime`,`Telephone`,`Email`,`Image1`,`ImageName1`,`Image2`,`ImageName2`,`Image3`,`ImageName3`)
SELECT `OrderNo.`,`NIC`,`DP`,`Address`,`DPTime`,`Telephone`,`Email`,`Image1`,`ImageName1`,`Image2`,`ImageName2`,`Image3`,`ImageName3` FROM `order` WHERE `OrderNo.` = '$id' ";
$res1= mysqli_query($db,$sql1) or die("Failed".mysqli_error($db));
$sql2= "DELETE FROM `order` WHERE `OrderNo.` = '$id' ";
$res2= mysqli_query($db,$sql2) or die("Failed".mysqli_error($db));
echo "window.location.href=vieworders.php";
}
?>
Though sql queries are successfully(transfer and deletion) executed i get the error 'The requested URL was not found on this server" when loading the page vieworders.php! how can i correct this?
</div>
I'm guessing you have already put this inside a script tag otherwise you wouldn't be getting this error.
Your redirect should show as:-
echo 'window.location="vieworders.php"';
or use:-
header("Location: vieworders.php");