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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:22:57+00:00 2026-06-11T21:22:57+00:00

PHP problem here, I’ve made a login/logout kind code, with a insert and delete

  • 0

PHP problem here, I’ve made a login/logout kind code, with a insert and delete function that stand by login and logout.

So the problem is that after I insert the the text I simply cannot delete it, cause the delete button is like a simple
turn back botton, and doesn’t make his work, nothing
in the if(isset($_POST['delete'])) condition seems to work.

May the problem be that I’m using two void action
that refer to the same page? cause the first button
work and the second not.

Anyone can understand why?

<html>
  <header></header>
  <body>
    <!-- START PHP --> 
    <?php
      //If not submit i put the submit form
      if(!isset($_POST['send'])){
        echo "<form name='send' action='' method='POST'>
          <input type='text' name='text' value=''/>
          <input type='submit' name='send' value='send' />
          </form>";
      }<!-- IF END --> 

      //If submit was set I insert $text into the db and I render
      //the delete button
      else {
        $conn= mysql_connect('localhost','root','');
        mysql_select_db('db_try',$conn ) or die(mysql_error());
        $dato=$_POST['dato'];
        mysql_query(" INSERT INTO test (value) VALUES ('$text') ") or die(mysql_error());
        echo "Operation complete";

        //Now i render the delete submit button...
        echo "<form name='delete' action='' method='POST'>
          <input type='submit' name='delete' value='delete' />
          </form>";

        //...and if i push it NOTHING, like it's only
        //a return to the first form button
        if(isset($_POST['delete'])){
          mysql_query(" DELETE FROM test WHERE value='$text' ") or die(mysql_error());
          echo "<br>Text'".$text."' deleted";
        }
      }<!-- ELSE END--> 
    ?><!-- END PHP -->
  </body>
</html>
  • 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-11T21:22:59+00:00Added an answer on June 11, 2026 at 9:22 pm

    Here is the right way to do this, it is a quick tip, you need to work a little more on mysql insert security etc.

    <html>
    <header>
    <body>
    
    <?php
    
        $conn= mysql_connect('localhost','root','');
        mysql_select_db('db_try',$conn ) or die(mysql_error());
    
        if(isset($_POST['send'])){
    
            $text = $_REQUEST['text'];
    
            mysql_query(" INSERT INTO test (value) VALUES ('$text') ") or die(mysql_error());
    
            $answer = "Operation complete";
    
            $form = "<form name='delete' action='' method='POST'>
                    <input type='submit' name='delete' value='delete' />
                    </form>";
    
        }
    
        else if(isset($_POST['delete'])){
    
            mysql_query(" DELETE FROM test WHERE value='$text' ") or die(mysql_error());
    
            $answer = "Text'".$text."' deleted";
    
        }
        else {
    
            $form = "<form name='send' action='' method='POST'>
                    <input type='text' name='text' value=''/>
                    <input type='submit' name='send' value='send' />
                    </form>";
    
        }
    
        print "<h1>" . $answer . "</h1>";
        print $form;
    
    ?>
    
    </body>
    </header>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a website that depends on PHP, AJAX and Javascript. The problem here
I need a function like var_dump($object) in php The problem is that the Var_dump
PHP/JQuery/AJAX problem's here: I have a button at the bottom of the page that
I have a problem here with the php function substr Let's say I have
first off I'm a noob to PHP but here is my problem. I am
I have a problem with sorting items in table in PHP. Here is what
I'm having a problem installing SAM 1.1.0 on fedora 16 same as here https://bugs.php.net/bug.php?id=59632&thanks=6
I have problem with php script. The thing is that it shows me, that
I have a problem in php code inserting values into database (I use PHPMyAdmin).
I have a z-index problem here: http://ratingscorner.com/product_rating.php?alias=Peoples-Education-Society-Institute-of-Technology-%28PESIT%29-100-feet-Ring-Road-Bangalore&product=Colleges The first level menus go behind the

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.