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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:22:38+00:00 2026-05-22T16:22:38+00:00

I am trying to set up a form with 2 buttons – DELETE which

  • 0

I am trying to set up a form with 2 buttons – “DELETE” which runs on the page delete.php and “EDIT” which runs on edit.php.

So I need a different action depending on which button they have clicked…

Here’s my code.

$con = mysql_connect("localhost","user","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("test", $con);

$result = mysql_query("SELECT * FROM myTable");

// Need to change the action depending on what button is clicked
echo "<form name='wer' id='wer' action='delete.php' method='post' >";
echo "<table border='1'>";

while($row = mysql_fetch_array($result))
  {
    echo "<tr>";
    echo "<td>" . $row['id'] . "</td>";
    echo "<td>" . $row['page_title'] . "</td>";
    echo "<td><input type='radio' name='test1' value='" . $row['id'] . "' /></td>";
    echo "</tr>";
  }

echo "<tr>";
echo "<td>&nbsp;</td>";
echo "<td>&nbsp;</td>";
echo "<td><input type='submit' name='delete' value='Delete' /> <input type='submit' name='edit' value='Edit' /></td>";
echo "</tr>";
echo "</table>";
echo "</form>";

mysql_close($con);
  • 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-22T16:22:38+00:00Added an answer on May 22, 2026 at 4:22 pm

    You could do that with JavaScript:

    <input type='button' value='Delete' onclick='
        this.form.action = "delete.php";
        this.form.submit();
    ' />
    

    Or you can do it with PHP, by having the form action be, say, action.php, which would contain:

    if (!empty($_REQUEST['delete'])) {
        require_once dirname(__FILE__) . '/delete.php';
    else if (!empty($_REQUEST['edit'])) {
        require_once dirname(__FILE__) . '/edit.php';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, so I have the form set to my PHP page. I also have
I'm currently trying to create buttons which are in the form of loosely stacked
I'm trying to create an edit page, which brings all of the original values
I am trying to set up a preview button in an edit form based
I am trying to handling datafrom's internal Add/Delete/Edit command form button control outside datafrom.
I am trying to set the click event of a button on my form
Im trying set the single table inheritance model type in a form. So i
im trying to set the height of two divs on my page, because my
I am trying to set a default button in my ASPX page. I have
I have an ASP.NET page (WebForm) on which I set the content of a

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.