The code below will save the input from Sweet Alert and save this to a database.
You need to prepare the MySQL saving page (addpage.php) and collect post data ‘pagename’
I have added my sweet alert cdn
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.28.2/sweetalert2.min.css"> <script src="//cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.28.2/sweetalert2.all.js"></script> <script> $(document).ready(function(){ $(document).on('click', '.addpage', function() { Swal.fire({ title: "NEW PAGE", text: "Add new page name below", input: 'text', showCancelButton: true }).then((result) => { if (result.value) { $.ajax({ url: "addpage.php", dataType: "html", type: 'POST', data: "pagename="+result.value, success: function(data){ alert(data); } }); //end ajax } //end if }); }); }); </script> |
Hope this works for you.