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 4055740
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:44:21+00:00 2026-05-20T14:44:21+00:00

I’m creating a new site for my project. I have made a index.php page

  • 0

I’m creating a new site for my project. I have made a index.php page and setup a login form and made the form action to the log.php page. Also after login, it must go to the account.php page. It works fine with the local server. But when I got online, while login a blank page comes in the log.php page. But the login happens and if I go to account.php by typing in the address bar, it works fine. The same with the Registration page also.

Here is the Log.php code:

 <?php
include("connection.php");
extract($_POST);
$password=md5($_POST['password']);
$query=mysql_query("SELECT * from register WHERE username='$username' and password='$password'");
$numrows=mysql_num_rows($query);
if($numrows!=0)
{
    $info = mysql_fetch_array($query); 
    session_start();
    $_SESSION[username]=$username;
    $_SESSION[fname]=$info['fname'];
    $_SESSION[lname]=$info['lname'];
    $_SESSION[email]=$info['email'];
    header("location:account.php");
}
else
header("location:login.php?i=invalid");

?>
  • 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-05-20T14:44:22+00:00Added an answer on May 20, 2026 at 2:44 pm

    First of all, escape your params to prevent SQL Injection, think about parsing something like

    '; DROP DATABASE xxxxx; as username;

    Also don’t extrac all post variables – only those what you need (it can be dangerous if you will use somewhere uninitlialised variable or checking with isset() , beaceouse someone can create one.

    For your problem:
    Then, check your file for characters before <?php. Sign < should be first byte in your code, because if you have output buffering off on your server – you cannot change already sended header – i mean, that when parser see some sign out off the php structure, it will send 200 OK code (not 30x redirect) with that data. Maybe you have invisible BOM at start of file (some special characters indicating that file is encoded in unicode), try editing with for example notepad++ to check this.

    It is also about connection.php, because that file is included.

    Try turning on error_reporting( E_ALL ); to see do you got “headers already sent” error.

    Use $_SESSION['lname'] not $_SESSION[lname].

    Don’t need if($numrows!=0), can be if($numrows) it’s cleaner (in my opinion).

    Try to hold your convention, if you write SELECT * from, then you should write SELECT * FROM.

    Get from database only fields that you need, so SELECT username,fname,lname,email not * (you don’t need password here, and if you ever add some fields to this table, those fields woudln’t be retreived here)

    You don’t even need to check count of rows:

    $numrows=mysql_num_rows($query); 
    if($numrows!=0) {
    $info = mysql_fetch_array($query);
    

    Just check that one row was retreived:

    $info = mysql_fetch_array($query);
    if($info)
    {
    

    and if you are using only text indexes of $info table, use mysql_fetch_assoc instead of mysql_fetch_array (second creates also indexes 0,1,2 and so on, with the same data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.