BasS™ Posted June 13, 2015 Share Posted June 13, 2015 Hello, i want to know how to make a button. When i click on it, it instert's a extra emty row in MySQL Table, it should to be used PHP and/or Ajax scripts.. I Searched for it on the internet, no luck.. i tried to instert like this PHP code include("connect.php"); if (mysql_query("INSERT INTO `list` (`id`, `name`, `from`, `birthdate`, `job`) VALUES ('$id', 'Name', 'From', 'Birthdate', 'job');")) { echo "success";} but how to make a button ? Sorry, i'm only beginner on PHP, MySQL.. Thanks :x Quote Link to comment Share on other sites More sharing options...
TJ. Posted June 13, 2015 Share Posted June 13, 2015 Do you mean something like the HTML button attribute?<button type="button">Click Me!</button> 1 Quote Link to comment Share on other sites More sharing options...
BasS™ Posted June 13, 2015 Author Share Posted June 13, 2015 (edited) Yeas, something like this, when you click on it, it insert's into Database extra row under all Edited June 13, 2015 by BasS™ Quote Link to comment Share on other sites More sharing options...
Cheerio Posted June 14, 2015 Share Posted June 14, 2015 You would use a form element that uses the post method and then have the connect.php include in the formprocess.php that filters the post data for sql injection and adds the table, not in a if statement like you had above. Quote Link to comment Share on other sites More sharing options...
BasS™ Posted June 14, 2015 Author Share Posted June 14, 2015 Thanks, it Work's. Close/Delete Quote Link to comment Share on other sites More sharing options...
flo110 Posted April 4, 2016 Share Posted April 4, 2016 Just gonna leave this here if anyone needs the AJAX implementation using JQuery. HTML: <button id="my_button">Click Me</button> JS: $("#my_button").click(function(){ $.ajax({url: "/path/to/connect.php", success: function(result){ alert("The result is:" + result); }}); }); After you clicked it and the query you made in the connect.php file, it should popup a message saying "success" or in case of failure nothing will happen. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.