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

  • SEARCH
  • Home
  • 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 8668465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:13:12+00:00 2026-06-12T18:13:12+00:00

this is the codes I used in my login(logging.php) page..what should I do with

  • 0

this is the codes I used in my login(logging.php) page..what should I do with this please?when tried to login the 1st account/other accounts..the login page is loaded but it does not redirect to any page instead, it only shows a blank page..
or if ever, my codes are wrong, can you please help me and provide a much better codes to replace this? any reply would be appreciated,thanks! 🙂 I badly needed this for a project..

<?php

session_start();
  $username = $_POST['username'];
  $password = $_POST['password'];

if ( isset ($_POST['username']) )
{
 $connect = mysql_connect("localhost","root","") or die ("could'nt connect to db");
 mysql_select_db("tesda") or die ("cant connect");
 $sql=("SELECT * FROM login WHERE username='$username'");
 $result=mysql_query($sql);
 $row=mysql_fetch_array($result);

 if($result !=0 )
 {
    while($row=mysql_fetch_assoc($result))
    {
        $username = $row['username'];
        $password = $row['password'];
    }

if($row['name'] == $_POST['name'])
{

    if($_POST['username']=='tesda1'){
    header('Location: expi1.php');
    }
    else if($_POST['username']=='tesda2'){ 
    header('Location: expi2.php');
    }
    else if($_POST['username']=='tesda3'){ 
    header('Location: expi3.php');
    }
    else if($_POST['username']=='tesda4'){ 
    header('Location: expi4.php');
    }
    else if($_POST['username']=='tesda5'){ 
    header('Location: expi5.php');
    }
    else if($_POST['username']=='tesda6'){ 
    header('Location: expi6.php');
    }
    else if($_POST['username']=='tesda7'){ 
    header('Location: expi7.php');
    }
    else if($_SESSION['username']="$dbusername"){
    header('Location: attempt1.php');
    }
    else if($_SESSION['username']="$dbusername"){
    header('Location: attempt2.php');
    }
    else if($_SESSION['username']="$dbusername"){
    header('Location: attempt3.php');
    }
}
}
}
?>
  • 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-12T18:13:14+00:00Added an answer on June 12, 2026 at 6:13 pm

    Please see if below code works out , I have made some minor changes…

     <?php
    
        session_start();
          $username = $_POST['username'];
          $password = $_POST['password'];
    
        if ( isset ($_POST['username']) )
        {
         $connect = mysql_connect("localhost","root","") or die ("could'nt connect to db");
         mysql_select_db("tesda") or die ("cant connect");
         $sql="SELECT * FROM login WHERE username='$username' AND password='$password'";
         $result=mysql_query($sql);
    
    
         if(mysql_num_rows($result)==1)
         {
    
            if($_POST['username']=='tesda1'){
            header('Location: expi1.php');
            }
            else if($_POST['username']=='tesda2'){ 
            header('Location: expi2.php');
            }
            else if($_POST['username']=='tesda3'){ 
            header('Location: expi3.php');
            }
            else if($_POST['username']=='tesda4'){ 
            header('Location: expi4.php');
            }
            else if($_POST['username']=='tesda5'){ 
            header('Location: expi5.php');
            }
            else if($_POST['username']=='tesda6'){ 
            header('Location: expi6.php');
            }
            else if($_POST['username']=='tesda7'){ 
            header('Location: expi7.php');
            }
    
        }else{
            header('Location:wrongattempt.php');
        }
        }
    
    ?>
    

    Create a seprate file to handle unsuccessful attempts and show number of unsuccessfull attempts.

    wrongAttempt.php

    <?php
    session_start();
    $attempt = ++$_SESSION['count'];
    echo 'Number of unsuccessful attempts = '.$attempt;
    
    echo '<a href="login.php">Try again</a>';
    
    
    ?>
    

    In your login page add the below line at start. I am assuming your login page is login.php.
    login.php

    session start();
    if(!isset($_SESSION['count']))
        $SESSION['count']=0; //initialize count session variable.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm using the kendo ui grid on my backbone application. i used this codes.
I've encountered many MATLAB codes which have a %#ok<SAGROW> comments. This comment is used
I have this login code, which works last night before I slept. Nobody used
I have a php script that is being used login into a remote site
As of this writing, I'm using PHP SDK v3.1.1-12, and I used the same
This is my login.php <form action=index.php method=get> <?php error_reporting(E_ALL & ~E_NOTICE); ?> <?php session_start();
i want to read the mails from gmail account.. i tried to login.. and
I was trying to create a secure login page with jsf, and I used
This code used to return my local ip address as 192.xxx.x.xxx but now it
This code used to work but doesnt any more. i used a breakpoint, and

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.