Advertisement
Guest User

Untitled

a guest
Jul 9th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. session_start();
  5.  
  6. $host="localhost"; // Host name
  7. $username="something"; // Mysql username
  8. $password="something else"; // Mysql password
  9. $db_name="users"; // Database name
  10. $tbl_name="members"; // Table name
  11.  
  12. // Connect to server and select database.
  13. mysql_connect("$host", "$username", "$password")or die("cannot connect");
  14. mysql_select_db("$db_name")or die("cannot select DB");
  15.  
  16. // Define $myusername and $mypassword
  17. if(!isset($_POST['myusername']) || !isset($_POST['mypassword']))
  18. {
  19. // Remove one of the following 2 lines.
  20. die("You are not logged in"); //display simple message
  21. header('Location: /login.php'); // or redirect to loginpage
  22. exit();
  23. }
  24. $myusername=mysql_real_escape_string($_POST['myusername']);
  25. $mypassword=mysql_real_escape_string($_POST['mypassword']);
  26.  
  27.  
  28. // Select table
  29. $result=mysql_query("SELECT * FROM members WHERE myusername='$myusername' AND mypassword='$mypassword'")
  30. or die(mysql_error());
  31. if(mysql_num_rows($result)!=1)
  32. {
  33. die('Bad username/password');
  34. }
  35. $row=mysql_fetch_array($result);
  36.  
  37.  
  38. ?>
  39.  
  40. <html>
  41. <head>
  42. <title>Portals</title>
  43. </head>
  44.  
  45. <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  46. <tr>
  47. <td>
  48. <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
  49. <tr>
  50. <td colspan="3"><strong>Portals</strong></td>
  51. </tr>
  52. <tr>
  53. <td width="22">1.</td>
  54. <td width="219">
  55.  
  56. <?php
  57. PRINT " <a href=".$row['portal1']."> ".$row['portal1']."</a>";
  58. ?>
  59.  
  60. </td>
  61. <td width="35">edit</td>
  62. </tr>
  63.  
  64. <tr>
  65. <td width="22">2.</td>
  66. <td width="219">
  67.  
  68. <?php
  69. PRINT " <a href=".$row['portal2']."> ".$row['portal2']."</a>";
  70. ?>
  71.  
  72. </td>
  73. <td width="35">edit</td>
  74. </tr>
  75.  
  76. <tr>
  77. <td width="22">3.</td>
  78. <td width="219">
  79.  
  80. <?php
  81. PRINT " <a href=".$row['portal3']."> ".$row['portal3']."</a>";
  82. ?>
  83.  
  84. </td>
  85. <td width="35">edit</td>
  86. </tr>
  87.  
  88. <tr>
  89. <td colspan="3" align="right">
  90.  
  91. <?php
  92. PRINT "$myusername";
  93. ?>
  94.  
  95. </td>
  96. </tr>
  97.  
  98. <tr>
  99. <td colspan="3" align="right"><a href='logout.php'>logout</a></td>
  100. </tr>
  101.  
  102.  
  103. </table>
  104.  
  105. </table>
  106.  
  107. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement