Reputation: 27
I want to back my form upload page after success to upload. alert is run well, but window location is not run.
Here my code. Thanks for help
if ($uploadKey)
{
?>
<script>
alert("Upload succesfull");
window.location ('= form_upload.php');
</script>
<?php
}
else{
?>
<script>
alert("Upload failed");
window.location('=form_upload.php');
</script>
<?php
}
Upvotes: 2
Views: 251
Reputation: 4239
You have written wrong window.location syntax. Please write as below:
window.location = "form_upload.php";
Instead of :
window.location ('= form_upload.php');
Upvotes: 1
Reputation: 157304
Did you cared to see the syntax? It should be
window.location = "PATH_TO_REDIRECT";
Also, you are using PHP, you should be using header()
instead of window.location
if ($uploadKey) {
header('Location: URL_HERE');
exit;
}
Upvotes: 4