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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:07:52+00:00 2026-06-10T07:07:52+00:00

hi i am new with php and mysql and i am working with a

  • 0

hi i am new with php and mysql and i am working with a website, i was reading some tutorials on how to create a login page, when i tried creating my own login page, seems that it stops in the script and doesnt proceed to the next page if login is successful

here is the code

master1.php
<form action="loginscript.php" method="post" name="loginform">
<table class="logintable">
<!-- username-->
<tr>
<td class="tdalignright"><strong>
Username:</strong>
</td>
<td>
<input type="text" name="uname" id="uname"/>
</td>
</tr>
<!-- password -->
<tr>
<td class="tdalignright"><strong>
Password:</strong>
</td>
<td>
<input type="password" name="pword" id="pword"/>
</td>
</tr>
<!-- login button -->
<tr>
<td>
</td>
<td class="tdalignright">
<input type="submit" name="Submit" value="Login" />
</td>
</tr>

</table> 
</form>

here is the login script

loginscript.php
<?php

$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password=""; // Mysql password 
$db_name="seelsdb"; // Database name 
$tbl_name="tblteacher"; // Table name 

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form 
$uname=$_POST['uname']; 
$pword=$_POST['pword']; 
// To protect MySQL injection (more detail about MySQL injection)
$uname = stripslashes($uname);
$pword = stripslashes($pword);
$uname = mysql_real_escape_string($uname);
$pword = mysql_real_escape_string($pword);
$sql="SELECT * FROM $tbl_name WHERE teacherEmail='$uname' and teacherPass='$pword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("uname");
session_register("pword"); 
header("location:schedule.php");
}
else {
echo "Wrong Username or Password";
}

?>

and here is the next page after a successful login

schedule.php

<?php
session_start();
if(!session_is_registered(uname)){
header("location:master1.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
LOGIN SUCCESSFUL
</body>
</html>

i cant seem to trace the error, hope you guys can help… 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-10T07:07:54+00:00Added an answer on June 10, 2026 at 7:07 am

    Your login script should be:

    $host="localhost"; // Host name 
    $username="root"; // Mysql username 
    $password=""; // Mysql password 
    $db_name="seelsdb"; // Database name 
    $tbl_name="tblteacher"; // Table name 
    
    // Connect to server and select databse.
    mysql_connect($host, $username, $password) or die("cannot connect"); 
    mysql_select_db($db_name)or die("cannot select DB");
    
    // username and password sent from form 
    $uname=$_POST['uname']; 
    $pword=$_POST['pword']; 
    // To protect MySQL injection (more detail about MySQL injection)
    $uname = stripslashes($uname);
    $pword = stripslashes($pword);
    $uname = mysql_real_escape_string($uname);
    $pword = mysql_real_escape_string($pword);
    $sql="SELECT * FROM $tbl_name WHERE teacherEmail='".$uname."' and teacherPass='".$pword."'";
    $result=mysql_query($sql);
    if(!$result)
    {
     echo 'Mysql did not respond to query'.mysql_error();
    }
    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);
    
    // If result matched $myusername and $mypassword, table row must be 1 row
    if($count==1){
    
    // Register $myusername, $mypassword and redirect to file "login_success.php"
    session_register("uname");
    session_register("pword"); 
    header("location:schedule.php");
    }
    else {
    echo "Wrong Username or Password";
    }
    
    ?>
    

    However, I will STRONGLY suggest you to opt for MySQLi instead of mysql_* functions. If you are comfortable also refer to PDO

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

Sidebar

Related Questions

I'm creating a website and new to php and mysql. I just read as
New to PHP and MySQL, have heard amazing things about this website from Leo
I am writing a new website that uses PHP and MySQL. I am trying
I am working on some PHP / mysql 5 web project involving a database
I'm currently working on creating a private messaging system, (PHP/MySQL) in which users can
Hi I'm really new to php/mysql. I'm working on a php/mysql school project with
I was reading my new php and MySQL book and it said that if
I was working on a rewards website in php and mysql. I have almost
I am pretty new to PHP and MySQL and I just can't figure this
I am fairly new to php and mysql but I have created a small

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.