Home php Edit popup not working

Edit popup not working

Author

Date

Category

Hello!
There is a workers table [id / steamid / wallet]. When you click on the “edit” button, a pop-up window for editing opens. But the id is not caught in the handler.
If, for example, you completely pervert and add “? Red_id = 1” in the address bar, then everything works. When you click on edit, a pop-up window opens and there you can edit the user with this id, and if you just click “edit”, an empty window will open
But why is the id not being passed?
Please help me figure it out.

& lt;? php
session_start ();
if (! isset ($ _ SESSION ["session_username"])) {
  header ("location: login.php");
}
? & gt;
& lt;? php include ("includes / header.php"); ? & gt;
& lt; head & gt;
 & lt; script src = "https://code.jquery.com/jquery-1.12.4.js" & gt; & lt; / script & gt;
 & lt; script src = "https://code.jquery.com/ui/1.12.1/jquery-ui.js" & gt; & lt; / script & gt;
 & lt; script & gt;
  $ (function () {
  $ ("#tabs") .tabs ();
 });
 & lt; / script & gt;
& lt; script & gt;
$ (document) .ready (function () {// all the magic after page load
  $ ('a # go'). click (function (event) {// catch a click on the link with id = "go"
    event.preventDefault (); // turn off the default element role
    $ ('# overlay'). fadeIn (400, // fade in the dark background first
      function () {// after executing the pre-animation
        $ ('# modal_form')
          .css ('display', 'block') // remove from the modal display: none;
          .animate ({opacity: 1, top: '50% '}, 200); // smoothly add transparency while sliding down
    });
  });
  / * Closing the modal window, here we do the same but in reverse order * /
  $ ('# modal_close, #overlay'). click (function () {// catch the click on the cross or overlay
    $ ('# modal_form')
      .animate ({opacity: 0, top: '45% '}, 200, // smoothly change the opacity to 0 and simultaneously move the window up
        function () {// after animation
          $ (this) .css ('display', 'none'); // make it display: none;
          $ ('# overlay'). fadeOut (400); // hide the background
        }
      );
  });
});
& lt; / script & gt;
& lt; script & gt;
$ (document) .ready (function () {// all the magic after page load
  $ ('a # go2'). click (function (event) {// catch a click on the link with id = "go"
    event.preventDefault (); // turn off the default element role
    $ ('# overlay2'). fadeIn (400, // fade in the dark background first
      function () {// after executing the pre-animation
        $ ('# modal_form2')
          .css ('display', 'block') // remove from the modal display: none;
          .animate ({opacity: 1, top: '50% '}, 200); // smoothly add transparency while sliding down
    });
  });
  / * Closing the modal window, here we do the same but in reverse order * /
  $ ('# modal_close2, # overlay2'). click (function () {// catch the click on the cross or background
    $ ('# modal_form2')
      .animate ({opacity: 0, top: '45% '}, 200, // smoothly change the opacity to 0 and simultaneously move the window up
        function () {// after animation
          $ (this) .css ('display', 'none'); // make it display: none;
          $ ('# overlay2'). fadeOut (400); // hide the background
        }
      );
  });
});
& lt; / script & gt;
& lt; / head & gt;
& lt; body style = 'overflow-x: hidden;' & gt;
    & lt; div id = "tabs" & gt;
  & lt; ul & gt;
  & lt; li & gt; & lt; a href = "# tabs-1" & gt; List of workers & lt; / a & gt; & lt; / li & gt;
    & lt; li & gt; & lt; a href = "# tabs-2" & gt; Your victims & lt; / a & gt; & lt; / li & gt;
    & lt; li & gt; & lt; a href = "# tabs-3" & gt; Free players & lt; / a & gt; & lt; / li & gt;
  & lt; / ul & gt;
  & lt; a href = "logout.php" & gt; & lt; img class = "img" src = "exit.png" alt = "" & gt; & lt; / a & gt;
& lt; div id = "tabs-1" & gt;
 & lt;? php
  $ host = "localhost";
  $ user = "root";
  $ pass = ""; // the password you set
  $ db_name = "pubg";
  $ link = mysql_connect ($ host, $ user, $ pass);
  mysql_query ("SET NAMES utf8");
  mysql_select_db ($ db_name, $ link); 
$ username = $ _ POST ['username1'];
  $ password = $ _ POST ['password1'];
 $ Steamid = $ _ POST ['SteamID1'];
 $ Wallet = $ _ POST ['WALLET1'];
 if (isset ($ _ get ['del_id'])) {// Checking whether there is a variable to remove
    $ sql = mysql_query ('delete from `workers` Where` id` ='. $ _ get ['del_id']); // Delete a string from the table
  }
   if (ISSET ($ _ get ['del_id2'])) {// Checking whether there is a variable to remove
    $ SQL = mysql_query ('delete from `Users` Where` id` =' $ _ get ['del_id2']); // Delete a string from the table
    Header ("Location: /Admin/intropage.php#tabs" ");
  }
 if (isset ($ _ post ['red_id'])) {// Check whether the variable is transmitted to edit
    If (ISSET ($ _ post ['username'])) {// if the new name is made, then update and the name and price
      $ SQL = MySQL_Query ('Update` workers` set'
          .''Sername` = "'. $ _ post [' username '].'", '
          .'Steamid` = '. $ _ post [' steamid '].', '
          . '`wallet` ='. $ _ post ['Wallet']. ' '
          .'Where` id` = '$ _ post [' red_id ']);
    }
  }
   if (ISset ($ _ post ["username1"])) {
  // Insert the data by substituting them into the request
  $ SQL = MySQL_Query ("Insert Into` Workers` (` group`, `steamid`,` wallet`, `username`,` password`)
            Values ​​(0, '$ Steamid', '$ Wallet', '$ Username', '$ Password') ");
   Header ("Location: /Admin/intropage.php");
   }
    ? & gt;
    & lt; div id = "modal_form" & gt;
   & lt; span id = "modal_close" & gt; & lt; img src = "icon.png" id = "modal_close" alt = "" & gt; & lt; / span & gt;
   & lt; p class = "p8" & gt; adding workers :) & lt; / p & gt;
    & lt; Table & gt;
    & lt; Form name = "" "Method =" POST "ACTION =" "& gt;
  & lt; TR & GT;
    & lt; p class = "TDD" & gt; login: & lt; / p & gt;
    & lt; Input Type = "text" class = "TD2" name = "username1" & gt;
  & lt; / tr & gt;
  & lt; TR & GT;
    & lt; p class = "TDD2" & gt; Password: & lt; / p & gt;
    & lt; Input Type = "text" class = "TD3" name = "password1" & gt;
  & lt; / tr & gt;
    & lt; TR & GT;
    & lt; p class = "TDD3" & gt; steam ID: & lt; / p & gt;
    & lt; Input Type = "text" class = "TD4" name = "steamid1" & gt;
  & lt; / tr & gt;
  & lt; p class = "TDD4" & gt; Wallet: & lt; / p & gt;
    & lt; Input Type = "text" class = "TD5" name = "Wallet1" & gt;
  & lt; / tr & gt;
  & lt; TR & GT;
    & lt; td colspan = "2" & gt; & lt; button class = "knopka2" & gt; ok & lt; / button & gt; & lt; / td & gt;
  & lt; / tr & gt;
& lt; / form & gt;
& lt; / Table & gt;
& lt; / div & gt;
& lt; div id = "overlay" & gt; & lt; / div & gt;
 & lt; Button class = "knopka" & gt; & lt; a href = "#" id = "go" & gt; add & lt; / a & gt; & lt; / button & gt;
  & lt; Table Border = '1' & gt;
& lt; TR & GT;
  & lt; th & gt; Name & lt; / th & gt;
  & lt; th & gt; Steam ID & LT; / TH & GT;
  & lt; th & gt; id & lt; / th & gt;
& lt; / tr & gt;
  & lt;? php
  $ SQL = MySQL_Query ("Select` ID`, `username`,` steamid`, `wallet` from` workers`, $ Link);
  While ($ result = mysql_fetch_array ($ SQL)) {
   if ($ result ['steamid'] == 0)
    $ result ['steamid'] = 'absent';
  Echo '& lt; TR & GT; & lt; TD & GT;'. $ result ['username']. '& lt; / td & gt;'.
       '& lt; TD & GT;' $ RESULT ['Steamid']. '& lt; / td & gt;'.
       '& lt; TD & GT;'. $ result ['id']. '& lt; / td & gt;'.
       '& lt; TD & GT; & lt; Button class = "Buton3" & gt; & lt; a href = "? Del_id ='. $ result ['id']. '" & gt; folk & lt; / a & gt; & lt; / button & gt; & lt; / TD & GT; '
       '& lt; TD & GT; & lt; Button class = "Buton3" & gt; & lt; a href = "? red_id ='. $ result ['id']. '" id = "go2" & gt; edit & lt; / a & gt; & lt; / Button & gt; & lt; / td & gt; & lt; / tr & gt; ';
}
? & gt;
& lt; / Table & gt;
& lt; div id = "modal_form2" & gt; & lt;! - SAO OKNO - & GT;
  & lt; span id = "modal_close2" & gt; & lt; img src = "icon.png" id = "modal_close2" alt = "" & gt; & lt; / span & gt;
  & lt;! - here is a delay - & gt;
  & lt;? php
  $ host = "localhost";
  $ user = "root";
  $ pass = "Goldberg";
  $ db_name = "pubg";
  $ link = mysql_connect ($ host, $ user, $ pass);
  mysql_select_db ($ db_name, $ link);
  If (ISset ($ _ post ['red_id'])) {
    $ SQL = MySQL_Query ("Select * from` workers` Where `id` =". $ _ get ['red_id'], $ LINK);
    $ result = mysql_fetch_array ($ SQL);
    ? & gt;
    & lt; Table & gt;
      & lt; Form Action = "" Method = "POST" & GT;
        & lt; TR & GT;
          & lt; input type = "hidden" name = "red_id" value = "& lt;? php echo ($ result ['red_id']);? & gt;" & gt; 
& lt; TD & GT; Name: & lt; / TD & GT;
    & lt; TD & GT; & lt; Input Type = "text" name = "username" value = "& lt;? php echo ($ result ['username']) ;? & gt;" & gt; & lt; / td & gt;
  & lt; / tr & gt;
  & lt; TR & GT;
    & lt; TD & GT; Steam ID: & lt; / td & gt;
    & lt; TD & GT; & lt; Input Type = "text" name = "steamid" value = "& lt;? php echo ($ result [steamid ']) ;? & gt;" & gt; & lt; / td & gt;
  & lt; / tr & gt;
    & lt; TR & GT;
    & lt; TD & GT; Wallet: & lt; / td & gt;
    & lt; td & gt; & lt; input type = "text" name = "wallet" value = "& lt;? php echo ($ result ['wallet']) ;? & gt;" & gt; & lt; / td & gt;
  & lt; / tr & gt;
          & lt; td colspan = "2" & gt; & lt; button class = "knopka2" & gt; ok & lt; / button & gt; & lt; / td & gt;
        & lt; / tr & gt;
      & lt; / form & gt;
    & lt; / Table & gt;
    & lt;? php
  }
  ? & gt;
& lt; / div & gt;
& lt; div id = "overlay2" & gt; & lt; / div & gt; & lt;! -
& lt; / div & gt;
 & lt; div id = "Tabs-2" & gt;
Hey
 & lt; / div & gt;
 & lt; div id = "Tabs-3" & gt;
  & lt; ul & gt;
  & lt; li & gt; id & lt; / li & gt;
  & lt; li & gt; Name & lt; / li & gt;
  & lt; li & gt; steamid & lt; / li & gt;
  & lt; / ul & gt;
  & lt; div class = "Box" & gt;
    & lt; div class = "Box-scroll" & gt;
      & lt; Table id = "TBL2" & gt;
& lt;? php
  $ sql = mysql_query ("Select` ID`, `name`,` steamid` from `Users`, $ Link);
  While ($ result = mysql_fetch_array ($ SQL)) {
  Echo '& lt; TR & GT; & lt; TD & GT;' $ RESULT ['ID']. '& lt; / td & gt;'.
       '& lt; TD & GT;'. $ result ['name']. '& lt; / td & gt;'.
       '& lt; TD & GT; & lt; a class = "a1" href = "http://steamcommunity.com/profiles/'.$Result['steamid']. '" target = "_ blank" & gt;' $ result [ 'Steamid']. '& lt; / a & gt; & lt; / td & gt;.
       '& lt; TD & GT; & lt; Button class = "Buton3" & gt; & lt; a href = "? del_id2 ='. $ result ['id']. '" & gt; folk & lt; / a & gt; & lt; / button & gt; & lt; / td & gt; & lt; / tr & gt; ';
}
? & gt;
& lt; / div & gt;
& lt; / div & gt;
& lt; / Table & gt;
  & lt; / div & gt;
& lt; / body & gt;

Answer 1

It is worth trying to add a hidden input with the “Red_ID” value. And in PHP check $ _post, and not $ _get.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions