Gravatar Avatar

Untitled

By: a guest on December 23, 2015  |  syntax: NONE  |  size: 1.8 KB  |  hits: 62  |  expires: never
download  |  raw  |  embed  |  report abuse
Copied
  1. <?php
  2. $servername = \"localhost\";
  3. $username = \"root\";
  4. $password = \"YN2NJLAa1\";
  5. $dbname = \"redstonegaming\";
  6. $ip = get_client_ip();
  7. $datetime = date(\"l jS of F Y h:i:s A\");
  8. $temp1 = $_GET[\"name\"];
  9. $temp2 = $_GET[\"comment\"];
  10. $comment = \"\";
  11. $commentname = \"\";
  12. if (strlen($temp1) < 1)
  13. {
  14.     echo \"<script>alert(\'Your message must be more than 0 characters!\');</script>\";
  15. }
  16.  
  17. else if (strlen($temp2) > 300)
  18. {
  19.     echo \"<script>alert(\'Your message must be less than 300 characters!\');</script>\";
  20. }
  21. else {
  22.     send();
  23. }
  24.  
  25. function get_client_ip() {
  26.     $ipaddress = \'\';
  27.     if (getenv(\'HTTP_CLIENT_IP\'))
  28.         $ipaddress = getenv(\'HTTP_CLIENT_IP\');
  29.     else if(getenv(\'HTTP_X_FORWARDED_FOR\'))
  30.         $ipaddress = getenv(\'HTTP_X_FORWARDED_FOR\');
  31.     else if(getenv(\'HTTP_X_FORWARDED\'))
  32.         $ipaddress = getenv(\'HTTP_X_FORWARDED\');
  33.     else if(getenv(\'HTTP_FORWARDED_FOR\'))
  34.         $ipaddress = getenv(\'HTTP_FORWARDED_FOR\');
  35.     else if(getenv(\'HTTP_FORWARDED\'))
  36.        $ipaddress = getenv(\'HTTP_FORWARDED\');
  37.     else if(getenv(\'REMOTE_ADDR\'))
  38.         $ipaddress =  getenv(\'REMOTE_ADDR\');
  39.     else
  40.         $ipaddress = \'UNKNOWN\';
  41.     return $ipaddress;
  42. }
  43.  
  44. // Create connection
  45. $conn = new mysqli($servername, $username, $password, $dbname);
  46. // Check connection
  47. if ($conn->connect_error)
  48. {
  49.     echo \"<script>alert(\'Connection failed: \' . $conn->connect_error);</script>\";
  50. }
  51.  
  52. function send()
  53. {
  54.     $sql = \"INSERT INTO comments(Name, Message, Ip_Address, dateTime) VALUES (\'$commentname\',\'$comment\',\'$ip\',\'$datetime\')\";
  55. }
  56.  
  57. if ($conn->query($sql) === TRUE)
  58. {
  59.     echo \"<script>alert(\'New Record Created Successfully!\');</script>\";
  60. }
  61. else
  62. {
  63.     echo \"<script>alert(\'Error: \' . $sql . \'<br>\' . $conn->error\');</script>\";
  64. }
  65.  
  66. $conn->close();
  67. ?>
RAW Paste Data