Guest User

Untitled

a guest
Jan 10th, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.15 KB | None | 0 0
  1. <?php
  2.  
  3. session_start(); // Starting Session
  4. $adminedit = "Hey There";
  5. $error = ''; // Variable To Store Error Message
  6. if (isset($_POST['submit'])) {
  7.     if (empty($_POST['username']) || empty($_POST['password'])) {
  8.         $error = "Fields cannot be left blank";
  9.     } else {
  10. // Define $username and $password
  11.         $username = $_POST['username'];
  12.         $password = $_POST['password'];
  13. // Establishing Connection with Server by passing server_name, user_id and password as a parameter
  14.         $connection = mysql_connect("mysql.hostinger.co.uk", "u677311329_david", "32803280");
  15. // To protect MySQL injection for Security purpose
  16.         $username = stripslashes($username);
  17.         $password = stripslashes($password);
  18.         $username = mysql_real_escape_string($username);
  19.         $password = mysql_real_escape_string($password);
  20. // Selecting Database
  21.         $db = mysql_select_db("u677311329_blog", $connection);
  22. // SQL query to fetch information of registerd users and finds user match.
  23.         $query = mysql_query("SELECT * FROM company WHERE password='$password' AND username='$username'", $connection);
  24.         $rows = mysql_num_rows($query);
  25.         if ($rows == 1) {
  26.             $_SESSION['login_user'] = $username; // Initializing Session
  27.             $query = mysql_query("SELECT * FROM company WHERE password='$password' AND username='$username' AND permissions = 'admin'  ", $connection)or die(mysql_error());
  28.             $rows = mysql_num_rows($query);
  29.             if ($rows == 1) {
  30.                 $adminedit = <<<HTML
  31. <form>
  32. <textarea name='editor1' id='editor1' rows='10' cols='80'>
  33. This is my textarea to be replaced with CKEditor.
  34. </textarea>
  35. <script>
  36. // Replace the <textarea id='editor1'> with a CKEditor
  37. // instance, using default configuration.
  38. CKEDITOR.replace( 'editor1' );
  39. </script>
  40. </form>
  41. HTML;
  42.             }
  43.             else {
  44.                 $adminedit = "<textarea></textarea>";
  45.             }
  46.             header("location: profile.php"); // Redirecting To Other Page
  47.         } else {
  48.             $error = "INVALID USERNAME OR PASSWORD";
  49.         }
  50.  
  51.         mysql_close($connection); // Closing Connection
  52.     }
  53. }
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment