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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:47:09+00:00 2026-05-27T13:47:09+00:00

I have this login script, but for some reason its not working. I checked

  • 0

I have this login script, but for some reason its not working. I checked the database, the form, and I have re-written the script in like 5 different ways; however, they all have the same problem, it does not start the session. Here is the code:

<?php 
session_start();

//connect and select DB
mysql_connect ("localhost", "root", "") or die ('Error: ' . mysql_error());
mysql_select_db('usr_info')or die ("cannot select DB :(");

//transfer values sent from form
$usrname = $_POST['usrname'];
$passwrd = $_POST['passwrd'];

//injection protection
$usrname = stripslashes($usrname);
$passwrd = stripslashes($passwrd);
$usrname = mysql_real_escape_string($usrname);
$passwrd = mysql_real_escape_string($passwrd);

$sql = "SELECT * FROM usrs
        WHERE usremail='$usrname'
        and passwrd='".md5($_POST['passwrd'])."'";
$result = mysql_query($sql);

//count the number of rows found with the given info
$count = mysql_num_rows($result);

//the matched result must be equal to 1
if ($count == 1) {
    $_SESSION['u_name'] = $usrname;
    header("Location: ../../landing.php");
    exit();
}
else {
    echo "Wrong Username or Password";
}

this is the form im using:

<div id="login-signup" class="letters2"><a href="javascript:blankfunction()">Login | Signup</a></div>
<div id="point-1" class="point-1"><img src="site-wide/point-1.png" width="405" height="131" />
  <div id="login-form">
  <form id="login" method="POST" action="site-wide/effects/login.php">
    <label for="username"></label>
    <input type="text" name="usrname" id="usrname" value="email" onfocus="clearMe(this);" onblur="unClearMe(this);"/>
    <label for="passwrd"></label>
    <input type="password" name="passwrd" id="passwrd" value="password" onfocus="clearMe(this);" onblur="unClearMe(this);"/>
    <input type="image" src="site-wide/submit.png" name="submit" id="submit" value="login"/>
  </form>

this is the usrs table in my db:

usrs

Field    Type          Null  Default  Comments  
ID           int(4)        No  
usrfname     varchar(15)   No    
usrlname     varchar(15)   No        
usremail     varchar(45)   No   
passwrd      varchar(8)    No  
usrage       int(3)        No 
usrgender    varchar(7)    No  

I found the answer xD .. the problem was the database. the password field only had 8 characters whereas the actuall md5 password had over 15. so all i did was increase the number of characters the field can handle and viola!

  • 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-27T13:47:10+00:00Added an answer on May 27, 2026 at 1:47 pm

    Works fine on my end, just adding what jogesh_p suggested.

    Please check if the session has been started prior to continue with the rest of the script. May it be throwing any error? Set the error_reporting like that:

    <?php
    error_reporting(E_ALL);
    if (!session_start()) {
        die("The session hasn't been started!");
    }
    

    This way you can check if there’s any error before proceeding.

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

Sidebar

Related Questions

I'm sure this is a stupid question but for some reason its not showing
I have this situation: There are a login page with a login form (form
I have a login form for my website. This login form have two text
I have a login screen that I force to be ssl, so like this:
I have one image submit button like this <input id=enter name=enter type=image value=Login src=images/btn_login.jpg/>
I am working on my first login script. I have been following examples from
I have this in my header: <script src=http://connect.facebook.net/en_US/all.js></script> Then I have the FB login
This is mostly an experiment , but I do think it does have some
I need to login to some page by cURL in php. I have this
GAE 1.5.5 looks to have some excellent, long-waited for features. However, they're not working

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.