Advertisement
Guest User

Untitled

a guest
Mar 19th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <?php // Start PHP.
  2.  
  3. // Database Connection Info.
  4. $servername = getenv('IP');
  5. $username = 'jackmoss';
  6. $password = '';
  7. $database = 'title';
  8.  
  9. // This line of code connects us to the database.
  10. $db = new mysqli($servername, $username, $password, $database);
  11.  
  12. // This now checks that we have connected to the database.
  13. // If we have an error, it will run the die statement.
  14. if($db->connect_error) {
  15.  
  16. // This die statement displays to the user that there was an error.
  17. die("Connection failed due to error: " . $db->connect_error);
  18. }
  19.  
  20. // If we connected to the database, our statement will continue here.
  21. // This statement creates our query which will get the page title header from the database
  22. // and then post it back.
  23. $sql = "UPDATE titleHeader SET title = '".$_POST["title"]."'";
  24.  
  25. // We will now query and store this data.
  26. $result = $db->query($sql);
  27.  
  28. // This if statement checks that the data we have collected is usable.
  29. // If this data is not usable, it will display an error.
  30. if(!$result)
  31. {
  32. error_log("Error updating title: ".$result->error);
  33. echo error_log;
  34. }
  35.  
  36. // The page will now refresh and show the new header.
  37. echo "<SCRIPT type='text/javascript'>
  38. window.location.replace(\"cms.php\");
  39. </SCRIPT>";
  40.  
  41. exit();
  42.  
  43. ?> <!-- End PHP -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement