Level 1
Nevermind, found the solution.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I'm using Vue Resource to send form data to PHP but for some reason the isset check for my submit button isn't working. However it does work when I turn off preventDefault and go directly to the PHP page. I've tried everything I can think of so I'd really appreciate some help.
PHP
if(isset($_REQUEST['submit'])){
echo json_encode($_REQUEST);
}
JS
this.$http.post('http://localhost/musicdatabase/addalbum.php', new FormData($('#submitalbum')))
.then(data => console.log(data.body));
HTML
<form class="col s12" id="submitalbum" method="post" action="addalbum.php">
<div class="row">
<div class="input-field col s6">
<input name="artist" placeholder="Artist" type="text">
</div>
<div class="input-field col s6">
<input name="title" placeholder="Title" type="text">
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input name="genre" placeholder="Genre">
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="released" type="number" name="released" placeholder="Year Released">
</div>
<button @click.prevent="addNewAlbum" type="submit" name="submit" class="waves-effect waves-light btn">Submit</button>
</div>
</form>
Please or to participate in this conversation.