Advertisement
Guest User

Untitled

a guest
Jul 1st, 2017
488
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.94 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.    
  4.     function doLogin()
  5.     {
  6.         //MySQL Connection Information
  7.         $dbhost = "db2698.perfora.net";
  8.         $dbuser = "dbo348993997";
  9.         $dbpass = "jonsull";
  10.         $dbname = "db348993997";
  11.        
  12.         //Initialize error variables
  13.         $errUser = false;
  14.         $errPass = false;
  15.    
  16.         //Encrypt user entered password
  17.         $password = md5($_POST['password']);
  18.         $username = $_POST['username'];
  19.        
  20.         $query = "SELECT * FROM users WHERE username='$username'";
  21.        
  22.         // Make SQL Connection
  23.         mysql_connect($dbhost,$dbuser,$dbpass) or die(mysql_error());
  24.         mysql_select_db($dbname) or die(mysql_error());
  25.         $result = mysql_query($query) or die(mysql_error());
  26.        
  27.         //Check for any returns - throw error if no user by that name exists
  28.         if(mysql_num_rows($result)==0) $errUser = true;
  29.        
  30.         $user = mysql_fetch_array($result);
  31.        
  32.         //Check if the users passwords match
  33.         if($user['password'] != $password) $errPass = true;
  34.        
  35.         //Check if any errors occurred, if so redraw from with error flags
  36.         //If all information was correct allow login
  37.         if($errUser || $errPass)
  38.         {
  39.             showForm($errUser, $errPass);
  40.         }
  41.         else
  42.         {
  43.             session_register("username");
  44.             header("Location:/customer");
  45.         }
  46.     }
  47.    
  48.     function doLogout()
  49.     {
  50.         session_destroy();
  51.         header('Location:/main');
  52.     }
  53. ?>
  54. <!DOCTYPE HTML>
  55. <head>
  56. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  57. <title>Kryptic Networks</title>
  58. <link rel="shortcut icon" href="favicon.ico">
  59. <link href="styles/reset.css" rel="stylesheet" type="text/css" />
  60. <link href="styles/main.css" rel="stylesheet" type="text/css" />
  61. </head>
  62. <body>
  63. <div id="toptail" class="toptail">
  64.     <div id="info">
  65.         <div id="time"><?php echo date('l, F d, Y g:i');?></div>
  66.         <div id="email"><a href="mailto:support@krypticnetworks.com">support@krypticnetworks.com</a> | <?php if(!session_is_registered("username")) { echo '<a href="/login">Customer Login</a>'; } else { echo 'Welcome back,'.$_SESSION['username'].' | <a href="/logout">Logout</a>'; } ?></div>
  67.     </div>
  68.     <div id="nav">
  69.         <ul>
  70.             <li class="first"><a href="/">Main</a></li>
  71.             <li><a href="/about">About Kryptic <img src="images/downarrow.png"></a>
  72.                 <ul>
  73.                     <li><a href="/history">History</a></li>
  74.                     <li><a href="/team">Our Team</a></li>
  75.                     <li><a href="/archive">News Archive</a></li>
  76.                 </ul>
  77.             </li>
  78.             <li><a href="/services">Services <img src="images/downarrow.png"></a>
  79.                 <ul>
  80.                     <li><a href="/infra">Infrastructure</a></li>
  81.                     <li><a href="/hardware">Hardware</a></li>
  82.                     <li><a href="/monitoring">Monitoring</a></li>
  83.                     <li><a href="/security">Security</a></li>
  84.                     <li><a href="/routing">Routing</a></li>
  85.                     <li><a href="/managed">Managed Services</a></li>
  86.                 </ul>
  87.             </li>
  88.             <li><a href="/solutions">Solutions</a></li>
  89.           <li><a href="/support">Support</a></li>
  90.             <li><a href="/contact">Contact us</a></li>            
  91.       </ul>
  92.     </div>
  93. </div>
  94. <div id="misc" style="clear:left"><div id="logo"><img src="images/logo.png" width="262" height="73"></div>
  95.   <div id="empty">
  96.   </div>
  97. </div>
  98. <div id="middle" >
  99. <?php
  100.     $pid=$_GET['pid'];
  101.     if($pid=='' | $pid=='main') { include('main.php'); }
  102.     else if($pid=='about') { include('about.php'); }
  103.     else if($pid=='history') { include('history.php'); }   
  104.     else if($pid=='services') { include('services.php'); }
  105.     else if($pid=='solutions') { include('solutions.php'); }
  106.     else if($pid=='support') { include('support.php'); }
  107.     else if($pid=='contact') { include('contact.php'); }
  108.     else if($pid=='login') { include('login.php'); }
  109.     else if($pid=='customer') { include('customer.php'); }
  110.     else if($pid=='logout') { include('logout.php'); }
  111.     else if($pid=='404') { include('404.php'); }
  112.     else if($pid=='403') { include('403.php'); }
  113.     else if($pid=='401') { include('401.php'); }
  114.     else { include('404.php'); } ?></div>
  115. <div id="footer">
  116. </div>
  117. </body>
  118. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement