mysql - PHP Redirect stopped working? -
i have wrote script update mysql db form.
after db has been updated want page auto redirect page.
this has been working fine since switching hosting provider non of sites re-directs work.
here code:
<?php $servername = "localhost"; $username = "xxx"; $password = "xxx"; $dbname = "xxx"; // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $id= $_post[id]; $dob=$_post[dob]; $sql=("update users set dob='$dob' id='$id'")or die('error 23 ' . mysql_error()); if ($conn->query($sql) === true) { echo "updated successfully<br /><br />"; } else { echo "error: " . $sql . "<br>" . $conn->error; } ?> <?php header("location:index.php?action=updated"); ?> when run code db updates page displays updated successfully?
don't echo , try redirect afterwards. instead redirect without echoing.
if ($conn->query($sql) === true) { header("location:index.php?action=updated"); exit; } else echo "error: " . $sql . "<br>" . $conn->error;
Comments
Post a Comment