Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- //$valid = $_SESSION['username'];
- if($_SESSION['username'] == true){
- print_r($_SESSION);
- $message = "Welcome back dood";
- echo $message;
- }
- else
- {
- if(isset($_POST['submit']))
- {
- include 'dbConnect.php';
- $user = $_POST['username'];
- $pass = $_POST['password'];
- $sql = "SELECT event_user_name, event_user_password FROM event_log_in WHERE event_user_name = 'username' AND event_user_password = 'password'";
- $query = $conn->prepare($sql) or die("<p>SQL String: $sql</p>");
- $query->execute()or die("<p>Execution </p>");
- //$query->store_result();
- $query->fetch();
- if ($_SESSION['username'] = true) //If this is a valid user there should be ONE row only
- {
- //this is a valid user so set your SESSION variable
- $message = "Welcome Back!";
- echo $message;
- //Valid User can do the following things:
- }
- else
- {
- //error in processing login. Logon Not Found...
- $_SESSION['username'] = false;
- $message = "Sorry, there was a problem with your username or password. Please try again.";
- echo $message;
- }
- //$query->close();
- //$conn->close();
- }
- }
- ?>
- <html>
- <head>
- </head>
- <body>
- <?php
- print_r($_SESSION);
- if ($_SESSION['username'] == true) //This is a valid user. Show them the Administrator Page
- {
- //turn off PHP and turn on HTML
- ?>
- <h3>Presenters Administrator Options</h3>
- <p><a href="contactForm1.php">Input New Contact</a></p>
- <p><a href="selectEvents.php">List of Contacts</a></p>
- <p><a href="logingOut.php">Logout of Contacts Admin System</a></p>
- <?php
- }
- else //The user needs to log in. Display the Login Form
- {
- ?>
- <form name = "form1" id = "form1" method = "post" action = "loginFile.php">
- <p>Please enter your username:
- <input type = "text" name = "username" id = "username">
- </p>
- <p>Please enter your password:
- <input type = "text" name = "password" id = "password">
- </p>
- <input type = "submit" name = "submit" id = "submit" value = "LOGIN">
- </form>
- <?php //turn off HTML and turn on PHP
- }//end of checking for a valid user
- //turn off PHP and begin HTML
- ?>
- <p>Return to <a href='#'>www.presentationstogo.com</a></p>
- </body>
- </html>
Add Comment
Please, Sign In to add comment