I want to load the same page after the form is submitted. So I have something like this:
if (isset($_POST['delete_video'])) {//go to db to delete}
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="POST">
<input type="submit" name="delete_video" value="Delete" onClick="javascript:return confirm('Delete this video?');"/>
This doesn’t work for me. But if I remove the echo it does work:
<form action="<?php htmlentities($_SERVER['PHP_SELF']); ?>" method="POST">
How does this make sense?
Use
$_SERVER['REQUEST_URI']instead. This will give you the current URL, butPHP_SELFgives the path to file, which you don’t want in this case.