Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start(); // Starting Session
- $adminedit = "Hey There";
- $error = ''; // Variable To Store Error Message
- if (isset($_POST['submit'])) {
- if (empty($_POST['username']) || empty($_POST['password'])) {
- $error = "Fields cannot be left blank";
- } else {
- // Define $username and $password
- $username = $_POST['username'];
- $password = $_POST['password'];
- // Establishing Connection with Server by passing server_name, user_id and password as a parameter
- $connection = mysql_connect("mysql.hostinger.co.uk", "u677311329_david", "32803280");
- // To protect MySQL injection for Security purpose
- $username = stripslashes($username);
- $password = stripslashes($password);
- $username = mysql_real_escape_string($username);
- $password = mysql_real_escape_string($password);
- // Selecting Database
- $db = mysql_select_db("u677311329_blog", $connection);
- // SQL query to fetch information of registerd users and finds user match.
- $query = mysql_query("SELECT * FROM company WHERE password='$password' AND username='$username'", $connection);
- $rows = mysql_num_rows($query);
- if ($rows == 1) {
- $_SESSION['login_user'] = $username; // Initializing Session
- $query = mysql_query("SELECT * FROM company WHERE password='$password' AND username='$username' AND permissions = 'admin' ", $connection)or die(mysql_error());
- $rows = mysql_num_rows($query);
- if ($rows == 1) {
- $adminedit = <<<HTML
- <form>
- <textarea name='editor1' id='editor1' rows='10' cols='80'>
- This is my textarea to be replaced with CKEditor.
- </textarea>
- <script>
- // Replace the <textarea id='editor1'> with a CKEditor
- // instance, using default configuration.
- CKEDITOR.replace( 'editor1' );
- </script>
- </form>
- HTML;
- }
- else {
- $adminedit = "<textarea></textarea>";
- }
- header("location: profile.php"); // Redirecting To Other Page
- } else {
- $error = "INVALID USERNAME OR PASSWORD";
- }
- mysql_close($connection); // Closing Connection
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment