Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8797219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:48:29+00:00 2026-06-13T23:48:29+00:00

In the context of a form without a submit button, I am not understanding

  • 0

In the context of a form without a submit button, I am not understanding why the $_POST variable doesn’t get set. Here is my code:

<?php
  $view="blablabla";
?>
<form class="" method='POST' accept-charset="UTF-8" action='index.php'>
<p>
  <textarea rows="4" cols="60" name='article' id='article' WRAP=SOFT>
    <?php
      echo $view;
    ?>
  </textarea>
</p>    
<p>
  <input type="button" name='do1' id='do1' value="do 1"/>
  <input type="button" name='do2' id='do2' value="do 2"/>
</p>
</form>

<?php
  var_dump("POST :",$_POST);
?>

Shouldn’t the var_dump show a value to $_POST once I click one of the 2 buttons?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:48:30+00:00Added an answer on June 13, 2026 at 11:48 pm

    Nope- the input types have to be submit (<input type="submit"/>) for the form to be submitted. A POST request has to be sent to your PHP script in order for there to be any values populated in the $_POST array 🙂

    EDIT: They don’t have to be submit, but in the case of the code above, with no external triggers on the buttons, you’ll need submit buttons 🙂

    For your multiple buttons issue:

    If you’re using JavaScript/Ajax to send the POST request to PHP on the button click, you’ll need to do something similar:

    if (isset($_POST['x'])) {
        var_dump($_POST);
        exit;
    }
    

    This is so the script doesn’t return the HTML of the page (i.e. your form)- this isn’t an issue if you’re POSTing to another page 🙂

    Below is some sample jQuery code to send some POST data on button click (not going to give you the exact code, you’ll have to modify it to your needs!)

    $('#my_button').click(function(){
        $.post('myfile.php', data, function(response) { //the var 'data' is the POST data you're sending
            // handle response here, the data being in the response variable 
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using php/ajax to submit a form without page refresh. Here are my
Need help in jquery: here is a schema of code: submit form through jquery
In Drupal, how do you get the submit button to appear last on a
I'm having a little 'teething' problem here is my code so far <form name=job_app>
I currently have a form set up that passes some data to a php
html in delete_define.php follows: <form action=delete_now.php onsubmit=my_funct();> <input type=submit name=my_submit class=my_submit value=submit/> </form> javascript
I'm going to get parameter form AJAX request in Django, Here's what I'm doing:
I am using AjaxForm plugin to submit my form without refresh. like: $('#my_form_id').ajaxForm(function(){ //something
I have a file named discussion.php , where a form is located. In this
I have the following html button <td><form id=form2 name=form2 method=post onclick=../cgi-bin/py/GuestBookEntry.py> <input type=submit name=gBookSrib

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.