Jump to content

Search the Community

Showing results for tags 'remove form when used php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi guys - I've had problems with this for a couple of hours now, so now im asking you! ;-) I'm creating a blog, where i can log in in the header.php file (which i include on all the pages, as a sticky "move-around" -toolbar. But I would like the form to be removed when I am logged in, and instead have a log out button and preferences (or just to be removed as a start). I've tried to solve it by adding !$_session['user_id']{*FORM-CODE-WITH-INPUT-AREA-HERE}; meaning, that if the user is logged in, the above thing wont even come up. But i couldn't really make it work. Heres my code: <?php session_start(); if(isset($_POST['submit'])) { $user = $_POST['username']; $pwrd = $_POST['pwrd']; //include database connection include 'db_connect.php'; if(empty($user) || empty($pwrd)){ echo("Missing Information"); }else{ $user = strip_tags($user); $user = $db->real_escape_string($user); $pwrd = strip_tags($pwrd); $pwrd = $db->real_escape_string($pwrd); $pwrd = md5($pwrd); $query = $db->query("SELECT user_id, username FROM user WHERE username='$user' AND password='$pwrd'"); if($query->num_rows == 1){ while($row = $query->fetch_object()){ $_SESSION['user_id'] = $row->user_id; } header('Location: admin-page.php'); exit(); }else{ echo "Missing Information!"; } } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script src="http://code.jquery.com/jquery-1.5.min.js"></script> </head> <body> <div id="container"> <form action="login.php" method="post"> <p> <label>Username</label><input type="text" name="username"> <label>Password</label><input type="password" name="pwrd"> <input type="submit" name="submit" value="LogIn"> </p> </form> </div> </body> </html> And the code is by the way just the login.php, which i already included in the header.php.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.