I am no longer using extra pages to use functions within the PHP page. I use PDO with a php for the functions and use everything in the page without loading anything external.
My question is how to use ajax in this case. Home
I want to send a button of a form, but the function is inside the page.
I quit the code.
Here's an example to delete data:
Form submitted to this section
if (isset($_POST['deletepost'])){
if(empty($errors) === true){
$postiddel = $postid;
$users->deletepost($postiddel);
header('Location: home');
exit();
}
}
HTML
<form method="post" name="deleteform" action="">
<input type="text" name="postid" hidden value="<?php echo $postid; ?>">
<li><button type="submit" name="deletepost" class="dropdownbutton">Eliminar publicação</button></li>
</form>
What I need to do is run the php that is inside the same page without refreshing the page .... I do not know if this is possible, but I hope it is, because I'm tired of using external pages.