Jump to content

Search the Community

Showing results for tags 'login php script access redir'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 1 result

  1. Please, help. I'm new to php but I've tried so many times to make it work. I've wrote a script that reads user and password data correctly, to log into a reserved webpage. The problem is that when you press the login button, it doesn't redirect to the target.php (reserved) page. The form is in a file called login.php. It reads and connect to the db, but stays on this login page. As a matter of fact, if I manually type in the url mywebsite/target.php after putting the credentials, it works. But I need an automatic redirect from login.php page and if credentials are correct, redirect to target.php. <?php session_start(); function loginform(){ echo "<form action='' method='POST'> Username: <input type = 'text' name='username'> Password: <input type = 'text' name='password'> <input type = 'submit' name='login' value='Login'> </form> "; } function logoutform(){ echo "<form action='' method='POST'> <input type = 'submit' name='logout' value='Logout'> </form> "; } function login($username, $password){ $pass = md5($password); $con= mysqli(whateverwebsite.com, 'Nameofthetable', 'hashedmd5password') or die (mysql_error()); mysql_select_db('whateverdb', $con) or die (mysql_error()); $result = mysql_query(" SELECT * FROM user WHERE username='$username' AND password='$pass' ") or die (mysql_error); $count= mysql_num_rows($result); if($count==1) { $_SESSION['login']=$username; header('Location:Aggiornamenti/Aggiornamenti.php'); /*this doesn't actually work*/ } else { header('Location:index.php'); /*this doesn't actually work*/ echo "Wrong login"; } } function logout(){ session_destroy(); } if (isset($_SESSION['login'])) { /*this function seems to be ignored*/ echo "Success"; logoutform(); } else{ echo "Log in with username and password."; loginform(); } if ($_POST['login']) { login($_POST['username'], $_POST['password']); } elseif($_POST['logout']){ echo "you are logging out"; logout(); } ?> also, Before the html of the target.php page, there is this <?php session_start(); echo "Reserved area<br>"; if (!isset($_SESSION['login'])) { exit("you must login <a href='../login.php'>Login<a>"); } else { echo "Do the <a href='../login.php'>Logout</a>"; } ?>
  • 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.