I have a table in database mshop2, named userdb
named mshop2.script with all the functions stored in my JS file Where the Deliver User Function is also stored, which will jumps to a file named deleteUser.php
The php file where I want to run the code is admin.php and it was written in Is:
& lt; Font color = "white" & gt; Deletion - id & lt; / Font & gt; & Lt; Input class = "test1" type = "text" id = "txUserid" value = "" & gt; & Lt; Input class = "test2" name = "submit" type = "submit" value = "" id = "submit" onClick = 'deleteUser (); TxUserid.value = ""; ' /> The words 'input class' are just going to match an image folder to show an image according to my CSS file, on which I want to run the code when I Let me focus on it. I've included these lines at the top of my .php file:
& lt; Script src = 'jquery.js' & gt; & Lt; / Script & gt; & Lt; Script src = 'mshop2.script.js' & gt; & Lt; / Script & gt; I have written it on my mshop2.script.js file:
function deleteUser () {var userid = $ ('# txUserid'). Val (); Var finalized = {uid: userid}; $ .post ('deleteUser.php', last data, function) {if (resp == 'success') {Warning ('User successfully deleted.'); GetUserList ();}}); } This is the contents of my deleteUser.php file:
Nothing is happening and if I enter '1' or any number from 1 to 5 in the text box with the same ID in the matching line in my table What is wrong with my code?
You mislead a variable and confuse that u.
In your script code, come Passed the value of UID to the value of the user id and you instead of deleteUser.php > Mysql_real_escape_string ($ _ POST ['userid']);
Change to mysql_real_escape_string ($ _POST ['uid']); And in your query, just use the variable $ uid to $ id just use the same variable that you entered in your script so that your It is not difficult to see common mistakes.
Edit :: Try to remove the onclick event. Your HTML code
& lt; Script src = "// ajax.googleapis.com/ajax/li bs / jQuery / 1.10.1 / jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ (Document) .ready (function () {$ ("test2"). Click (function () {var id = $ ("# tsUserid"). Val (); $ .post ("deletUser.php", {Id: id}, function (data) {warning (data);});});}); & Lt; / Script & gt; Your php will be your deleteUser.php and simply
change mysql_real_escape_string ($ _ POST ['userid']); mysql_real_escape_string ($ _ POST ['id']); and delete your query from $ q = "userdb, id id = '$ id' '; Helps.
No comments:
Post a Comment