Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. <script>
  2.  
  3. function tSQLInjection(id){
  4. document.getElementById('message').innerHTML = "";
  5. var format = /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/;
  6. var str = document.getElementById(id).value;
  7. if(format.test(str)){
  8. document.getElementById(id).value = "";
  9. document.getElementById('message').innerHTML = "Please Key in valid characters!. Your text is [" + str + "]";
  10. }
  11. }
  12.  
  13. </script>
  14.  
  15. <?php
  16.  
  17. function chkSQLInjection($text){
  18. $vTF = false;
  19. if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $text)) {
  20. echo "has special character";
  21. $vTF = false;
  22. }
  23. return $vTF;
  24.  
  25. }
  26. if( isset($_POST["btnSubmit"]) ) {
  27. $userid = $_POST["txtuserid"];
  28. $pass = $_POST["txtpassword"];
  29. $username = $_POST["txtname"];
  30.  
  31.  
  32. mysql_connect("localhost","root","") or die("Cannot Connect to DB Server!");
  33. mysql_select_db("dbsec") or die("Cannot Select database");
  34.  
  35. $vSQL = " Insert into umaster (userid, password, username) values ( ";
  36. $vSQL .= " '$userid', '$pass', '$username' ) ";
  37.  
  38. mysql_query($vSQL);
  39. echo $vSQL;
  40.  
  41. }
  42.  
  43.  
  44.  
  45. ?>
  46.  
  47. <html>
  48. <head>
  49. <title>Web Security</title>
  50. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  51. </head>
  52. <body>
  53. <center>
  54.  
  55. <form method="post">
  56. User id :<input id="txtuserid" name="txtuserid" type="text" value="" size="30" onMouseUp="tSQLInjection(this.id)" onKeyUp="tSQLInjection(this.id)" />
  57. <br>
  58. Password:<input id="txtpassword" name="txtpassword" type="text" value="" size="30" onMouseUp="tSQLInjection(this.id)" onKeyUp="tSQLInjection(this.id)" />
  59. <br>
  60. Name :<input id="txtname" name="txtname" type="text" value="" size="30" onMouseUp="tSQLInjection(this.id)" onKeyUp="tSQLInjection(this.id)" />
  61. <br>
  62. <input type="submit" name="btnSubmit" value="Insert" />
  63. </form>
  64. <hint id="message"></hint>
  65. </center>
  66. </body>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement