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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:33:46+00:00 2026-06-01T22:33:46+00:00

So this time I decided to go with a web programming language. I always

  • 0

So this time I decided to go with a web programming language.

I always liked the way PHP worked, so I started learning it. I’ve started making a login page but I just don’t know whats wrong with it. No errors if I use symbols.

I don’t even think the form is processed. Is this the correct way to handle a form on the same page?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<?php
session_start();
include("includes/connect.php");

if (isset($_SESSION['uid'])) {
    header('Location:member.php');
}

if (isset($_POST['submit'])) {
    $error = array();
    
    //username
    if (empty($_POST['username'])) {
        $error[] = 'You cant have no username can you';
    } else if (ctype_alnum($_POST['username'])) {
        $username = $_POST['username'];
    } else {
        $error[] = 'Username cannot contain symbols';
    }
    
    //password
    if (empty($_POST['password'])) {
        $error[] = 'YOU NEED A PASSWORD';
    } else {
        $password =  sha1(mysql_real_escape_string($_POST['password']));
    }
    
    //error
    if (empty($error)) {
        $result = mysql_query("SELECT * FROM user_info WHERE username='$username' AND password='$password'") or die(mysql_error());
        if (mysql_num_rows($result) == 0) {
            $error_message='Username or Password wrong';
        } else {
            $_SESSION['username'] = $username;
            $_SESSION['user_id'] = mysql_result($result, 0, 'user_id');
        }
    } else {
        foreach($error as $key => $values) {
            $error_message.= "$values";
        }
    }
}


?>

<html>
<head>
    <title>Login :)</title>
</head>
<body>
<div style="background-color:#A0A0A0" align="center">
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
    <h3>Login</h3>
    <div>
        <label for="username">Username:</label>
        <input type="text" name="username" maxlength="10"/>
    </div>
    <div>
        <label for="password">Password:</label>
        <input type="password" name="password" maxlength="20"/>
    </div>
    <div>
        <input type="submit" name="submit "value="Login"/>
    </div>
</form>
<?php echo $error_message; ?>
</div>
</body
</html>
  • 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-01T22:33:48+00:00Added an answer on June 1, 2026 at 10:33 pm

    your body tag isn’t closed you forgot >

    </body>
    

    and delete the space in the submit button’s name 🙂

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

Sidebar

Related Questions

I'm learning web-centric programming by writing myself a blog, using PHP with a MySQL
Ok this time I decided to make a list using the STL. I need
This is the first time I'm creating an open-source project, and I've decided (based
I have seen this for a long time, and finally decided to put the
After quite a long time perusing the web i have decided to come here
Hi Masters Of Web Development. I have a not that simple question this time.
Its been quite some time since i have started developing web pages using JSF
I'm a long-time Flash developer who's recently decided to dive into HTML-based web apps,
today I discovered the wonderful world of CMS and decided to started exploring this
I am creating a web application with a non-popular programming language on the server

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.