Advertisement
Guest User

Untitled

a guest
Mar 5th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <?php
  2. $servername = "rdbms.strato.de";
  3. $username = "user";
  4. $password = "pw";
  5. $dbname = "name";
  6. $key = $_GET['key'];
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11. die("Connection failed: " . $conn->connect_error);
  12. }
  13. $sql = "SELECT * FROM table WHERE urlkey='$key'";
  14. $result = $conn->query($sql);
  15.  
  16. if ($result->num_rows > 0) {
  17. // output data of each row
  18. while($row = $result->fetch_assoc()) {
  19. header("Location:".$row['url']);
  20. exit;
  21. }
  22. } else {
  23. header("Location:/error");
  24. exit;
  25. }
  26. $conn->close();
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement