Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

adace1's avatar

Not getting back PHP form data

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>
0 likes
2 replies
adace1's avatar

Nevermind, found the solution.

Snapey's avatar

add a value= to the submit button input field.

and if you find a solution, please post what it was so that others can see it in the future when they find your question.

Please or to participate in this conversation.