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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:38:52+00:00 2026-05-24T04:38:52+00:00

I have written something like this in PHP <script type=text/javascript src=jquery.js></script></script> <script type=text/javascript> function

  • 0

I have written something like this in PHP

<script type="text/javascript" src="jquery.js"></script></script>
<script type="text/javascript">
 function get(){
$.post('output.php', { name: form.name.value },
function(output) {
    $('#age').html(output).show();

}) ;

}

</script> 

<body> 
<p>
<form name="form">
id:
<input type ="text" name="name"><input type ="button" name="Submit_1" value ="Get          
Existing Data" onclick="get();">//gets info from DB

<p>url: <input type="text" name="calc_url"/></p>
<option value="abc">abc</option> 
</select><br/>
<input type="submit" name="Submit_2" value="submit" />
</form>
<div id="title"></div>   
</p>
</body>
</html>

Output.php

<?php
Connect to DB

$name = mysql_real_escape_string($_POST['name']);


if(isset($_POST['submit1'])){
if ($name==NULL)
echo "please enter an id!";
else
{   
$age= mysql_query("SELECT title FROM parentid WHERE id ='$name'");
$age_num_rows = mysql_num_rows($age);   
  if ($age_num_rows==0)
  echo "id does not exist";

 else
{
 $sql ="SELECT * FROM parentid WHERE id = '$name'";       
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$abc_output= "Existing data of the record <br />";      
$abc_output .="Title: " . $row['title'] . "<br />" ;
$abc_output .="Report No: " .  $row['reportno'] . "<br />" ;
 $abc_output .="URL: " .  $row['calc_url'] . "<br />" ; 
$abc_output .="Institution: " .  $row['institution'] . "<br />" ; 
 }
}
echo $abc_output;
}
}
 if (isset($_POST['Submit_2'])) {

$value = mysql_real_escape_string($_POST['name']);
$value1 = mysql_real_escape_string($_POST['title']);
$sql = " UPDATE parentid SET title='$value1' WHERE id ='$value'";
if (!mysql_query($sql)) 
{
die ('Error:' .mysql_error());

}
}



?>

This is what i have done and it does not work!!
But if the above is done individually i.e.,without if (isset()) it works(single button considered individually)

  • 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-05-24T04:38:52+00:00Added an answer on May 24, 2026 at 4:38 am

    You can detect which submit button has been pressed by checking for it’s existence:

    if (isset($_POST['Submit_2'])) {
      // "Submit_2" submit button was clicked
    }
    

    Edit:

    1. Your HTML syntax is incorrect.
    2. Write if(isset($_POST['name']) and not if(isset($_POST['submit1']), since the parameter name is name, indicated by the second parameter of the $.post() jquery’s method: $.post('output.php', { name: form.name.value },
    3. The documentation of jquery.post tells us that the query string (in either POST or GET request) is built from the second parameter of that method. Which means that the $_POST superglobal will have only one key-value pair. Test that by writing print_r($_POST) at the top of your PHP script.
    4. It’s not recommended to use deprecated Javascript methods, e.g.: form.name.value. Instead, fetch the value of a DOM object by referring to it’s id (best approach). For instance if your input button has an <input ... id="button1" />, then fetch it’s value with $('#button1').val()
    5. Try something like this:

      <form>
      <input type="text" name="name" value="">
      <input type="button" name="submit1" value="Submit1" id="g1" />
      <input type="button" name="submit2" value="Submit2" id="g2" />
      </form>  
      <script type="text/javascript" src="jquery.js"></script></script>
      <script type="text/javascript">
      $('input[name^="submit"]').click(function() {
          submit_name = $(this).attr('name')
          submit_value = $(this).val()
          $.post('output.php', { submit_name: submit_value },
          function(output) {
              // do something
          });
      });
      </script> 
      

      There was never really a submission of the form, but it was sent via ajax, thus there’s no input of type submit.

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

Sidebar

Related Questions

i have code written something like this. if(!isset($cid)) { echo <script type=\text/javascript\>alert('OOps, Something went
I have written something like this pretty easily in C# ( string GetUrl(new {
I have a Google Instant style search script written in jQuery. When a user
I have a Google Instant style search script written in jQuery. When a user
I have a search script written in jQuery. To submit a query a user
OK I have a mySQL Database that looks something like this ID - an
I have a Google Instant style search script written in jQuery. When a user
I have written/found a php script and I don't understand why it's working one
I have written a PHP script based on a piece of code I've found
I have written a PHP script on my local server to loop through an

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.