Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7858871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:38:42+00:00 2026-06-02T21:38:42+00:00

guys I’m pretty new for php i’m trying to make a login page. How

  • 0

guys I’m pretty new for php i’m trying to make a login page.

How can I redirect page if statement is true?

I tried iwth header(“location: nextpage.php”); but it doesn’t work

<html>
    <head>
        <title>Uploader</title>
    </head>
    <body>

        <form action="index.php" method="POST" enctype="application/x-www-form-urlencoded"> 
        <input id="login" class="username" type="text" name="username" autofocus placeholder="Username" maxlength="30"/>
        <input id="login" class="password" type="password" name="password" placeholder="Password" maxlength="15"/>
        <input id="login" class="submit" type="submit" value="Login" />
        <p>Last update <span id="lastupdate"><?php echo date('d-m-Y');?></span></p>

        <?php
        mysql_connect("localhost", "root","******") or die(mysql_error());
        mysql_select_db("login") or die(mysql_error());

        if(isset($_POST['username']) && isset($_POST['password'])){
            $db_user = mysql_query("SELECT username FROM login_tb");
            $db_pass = mysql_query("SELECT password FROM login_tb");
            $ctrl_user = mysql_result($db_user,0);
            $ctrl_pass = mysql_result($db_pass,0);

            $username = $_POST['username'];
            $password = $_POST['password'];
            echo $username . $password;

            if(($username || $password) == NULL){
                echo "you have entered wrong username or password! <br/> please contact site admin.";
            }else{
                if($username == $ctrl_user && $password == $ctrl_pass){
                header("location: ./nextpage.php");
                }
            }
        }
        ?>
    </body>
</html>

please anyone can help me? thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T21:38:50+00:00Added an answer on June 2, 2026 at 9:38 pm

    There are multiple ways to redirect pages, I like to do it as follows:

    <?php
    header('Location: /blah.php');
    die('<meta http-equiv="refresh" content="0; url=http:/blah.php" />\n
    <p>Please visit <a href="/blah.php">Blah.php</a>.</p>');
    ?>
    

    That way you have a fallback if the header fails.

    Also please allow me to point out that you should sanitise your data inputs to prevent SQL injection/XSS.
    Here:

    $user = htmlspecialchars(mysql_real_escape_string($_POST['user']));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Guys, this can't be for real I'm trying to make a .NET 2.0 executable
Guys, I've came across this problem I can't resolve myselg, I'm pretty sure I
Guys i am trying to connect my android app to php server and using
Guys How can I make this work `find /xyz/abc/music/ |grep def` I don't want
guys, I am trying to make use of glVertexAttribDivisor in my OpenGL instanced drawing.
guys, I'm trying to play a sound when hovering over a button. I've tried
Guys i am looking for some awesome tips for developing a page which allows
Guys, can someone give me a brief run through of how to change the
Guys, what is function called after my class loaded, where i can call self
guys, I want to set actions to touches. If people make single touch -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.