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 8329149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:40:38+00:00 2026-06-09T01:40:38+00:00

How do I execute PHP using a JavaScript onclick button? I can get the

  • 0

How do I execute PHP using a JavaScript onclick button?
I can get the form to submit, but the PHP does not get executed. I assume it’s because if(isset($_POST['form']))

Here is the PHP I want to execute:

if(isset($_POST['form']))
{
    if(!isset($error))
    {
        $database->query('UPDATE table SET field = :value WHERE id = :id', array(':field' => $value, ':id' => $id));
    }
}

Here is my button that is BEFORE my <form> tag:

<div onclick="javascript: $(\'#form\').submit();">Update</div>

And of course my <form> tag looks something like this:

<form name="form" id="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  <select name="value">
    <option value="1">Value1</option>
    <option value="2">Value2</option>
    <option value="3">Value3</option>
  </select>
</form>
  • 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-09T01:40:40+00:00Added an answer on June 9, 2026 at 1:40 am

    PHP generally runs server side. JavaScript generally runs in the browser. You need to put the PHP in the file blah.php on the server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jar file that I would like to execute using PHP, but
I want to redirect using .htaccess abc.com/test.php to abc.com/test . but it will execute/display
I'm using TinyMCE and want to execute a php script get the output and
I was wondering if I can use PHP and Javascript to get the screen
I'm using Javascript and I need to call a PHP file to execute some
I'm using php 5.3.2 and when i execute a curl it display the result
How do I properly execute commands in the command line using php? For example
Im using Debian testing, i have installed php-cli and when i try to execute
Does it possible to execute php file and store its output into some variable?
In file1.php , I execute file2.php with <form action=file2.php method=POST> Within file2, I want

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.