Advertisement
Guest User

Untitled

a guest
Sep 27th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <?php
  2.  
  3. $host="mysql11.000webhost.com";
  4. $username="a4264749_will16";
  5. $password="billyjoe16";
  6. $db_name="a4264749_members";
  7.  
  8.  
  9. $con=mysql_connect("$host","$username","$password") or die("Could not connect to database");
  10.  
  11. mysql_select_db("$db_name") or die ("Could not select Database.");
  12.  
  13. //strip tags from values to prevent SQL Injections
  14.  
  15.  
  16.  
  17.  
  18. $compname=(strip_tags($_POST['compname']));
  19. $compdesc=(strip_tags($_POST['compdesc']));
  20. $compslog=(strip_tags($_POST['compslog']));
  21.  
  22.  
  23.  
  24. //insert user stats into database
  25.  
  26.  
  27.  
  28.  
  29.  
  30. $sql=("INSERT INTO `a4264749_members` . `company stats` ( `id`, `company name`, `company description`, `company slogan`, `cash`, `staff`, `factories`, `skill level`, `materials`, `machines`) VALUES ('NULL','$compname','$compdesc','$compslog', '100000000', '2000', '1','1','1000','10')");
  31.  
  32.  
  33. $result=mysql_query($sql);
  34.  
  35. if (!$result)
  36.  
  37.  
  38. {
  39. echo "There was an error, please go back and try again";
  40. }
  41.  
  42. else
  43.  
  44. {
  45. echo "The company was successfully created";
  46.  
  47. }
  48.  
  49. mysql_close($con);
  50.  
  51. ?>
  52.  
  53.  
  54.  
  55. <html>
  56. <head>
  57. <style type="text/css">
  58. a:link {color:blue;text-decoration:none;}
  59. a:visited {color:blue;text-decoration:none;}
  60. a:hover {color:black;text-decoration:none;}
  61. </style>
  62. </head>
  63. <title> Create new company </title>
  64. <h1> Create new company </h1>
  65. <body>
  66. <body bgcolor="silver">
  67.  
  68. </br>
  69. </hr>
  70. </br>
  71. <form action="insert.php" method="POST" >
  72.  
  73.  
  74. <p> Company Name: <input type="text" name="compname" value="" maxlength="40" /> </p> </br>
  75. <p> Company Description: <input type="fieldarea" name="compdesc" value="" maxlength="600" /></p></br>
  76. <p> Company Slogan: <input type="text" name="compslog" value="" maxlength="40" /></p></br>
  77.  
  78. <input type="submit" name="submit" value="Create company" />
  79. </form>
  80. </body>
  81. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement