LANGUAGE PHP
Need help with login1.php
dbconfig.php
$server ="imc.kean.edu" $login ="john"; $password ="12345"; $dbname="CPS" ?>
----------------------------
login1.php
//configuration to connect to database
$host="localhost"; //server name
$dbuser="root"; //username
$pass=""; //password , default blank
$dbname="company"; //database name
//mysql_connect() is used to connect to the function
$conn=mysqli_connect($host,$dbuser,$pass,$dbname);
if(isset($_POST["btnSubmit"]))
{
$username=$_POST['username'];/ame
$password=$_POST['password'];//password
if($username=="" || $password=="")
{
//if username and password empty
echo "username and password can not be blank";
}
else
{
//converting username to lowercase
$username=strtolower($username);
//sql query
$sql_query="SELECT login,password FROM customers WHERE login='$username' or password='$password'";
//fetching records
//mysql_query() is used to perform queries it will return result set
$result_set=mysqli_query($conn,$sql_query);
//checking if result set is greater than 0 or not
if(mysqli_num_rows($result_set) > 0)
{
//if $res > 0
$row=mysqli_fetch_array($result_set);
//checking login
if($row['login']==$username)
{
//if login is correct then checking password
if($row['password']!=$password)
{
//if wrong password then
echo "Login ".$row['login']." exists, but password not matches.";
}
else
{ //login successfull message
echo "Login : ".$username." and Password : ".$password." are present.Login successfull";
}
}
else
{ //if login is not present
echo "Login ".$username." doesnt exist in the database";
}
}
else
{ //if username and password both wrong entered
echo "Login failed!";
}
}
}
?>
---------------------
index.html
Welcome to Johnson Willis project 1
Welcome to Johnson Willis project 1. Display all customers
Login ID: Password:
4. *(30 pts) Authentication: A program named "login1.php" be called to do the following functions after the Submit button is clicked. 4.1_ (10 pts) The customer login and password must be read from the table CPS3740.Customers. Login and password cannot be hard coded in the program. 4.2_ _ (5 pts)The input login should NOT be case sensitive, but the password should be case sensitive. 4.3_ (5 pts) If the login or password is empty, please show corresponding error messages and exit the program and NOT access the database. If both login and password are not empty, the program should access the table CPS3740. Customers to verify the login and password. 4.4_ (5 pts) If the login does not exist in the database, please display an error message "Login XXXX doesn't exist in the database" and exit the program. 4.5_ (5 pts) If the login exists in the database, but password doesn't match the record in database, please display an error message "login xxxx exists, but password not matches." and exit the program. 5. *(35 pts) Successfully login - If the login and password match the records in the database, your program "login1.php" should do the followings. Please refer to the project 1 main page shown in Figure 4. 5.1_ _(5 pts) Display the customer's name, age, street, city, zipcode. 5.2_ (10 pts) Display customer's IP address and display an message "You are (NOT) from Kean domain." under the IP address, if the customer (NOT) login from Kean domain (10.***) or (131.125.*.*) 5.2 (10 pts) Display all records and all columns in your Money_xxxx table that you created and inserted in Homework1. The results must be aligned using HTML
with meaningful headers. 53. (5 nts) If the type is denosit the amount should be shown in blue color. If the tune is withdraw Type here to search 1:22 PM 2/18/2019 5. *(35 pts) Successfully login - If the login and password match the records in the database, your program "login1.php" should do the followings. Please refer to the project 1 main page shown in Figure 4. 5.1 (5 pts) Display the customer's name, age, street, city, zipcode. 5.2_ (10 pts) Display customer's IP address and display an message "You are (NOT) from Kean domain." under the IP address, if the customer (NOT) login from Kean domain (10.**.*) or (131.125.*.*) 5.2_ (10 pts) Display all records and all columns in your Money_xxxx table that you created and inserted in Homework1. The results must be aligned using HTML with meaningful headers. 5.3 (5 pts) If the type is deposit, the amount should be shown in blue color. If the type is withdraw, the amount should be shown in red color. 5.4_ (5 pts) Calculate and display the balance under the table. Your IP: 100.100.100.100 You are NOT from Kean Unversity. Welcome Customer: Austin Huang age: 38 Address: 1000 Morris Ave., Union, 07083 The transcations for customer Austin Huang are: Saving account ID Code Operation Amount Date Time Note 1 xy001 Deposit 4000 2018-12-25 17:10:33 Manually inserted 2 Xy002 Withdraw -2000 2018-12-25 17:10:33 Manually inserted 3 Xy003 Deposit 3000 2018-12-25 17:10:33 Manually inserted 4 xy004 Withdraw |-1000 2018-12-25 17:10:33 Manually inserted Total balance: 4000 Figure 4. Project 1 main page after the customer login successfully 1:21 PM Type here to search 4. *(30 pts) Authentication: A program named "login1.php" be called to do the following functions after the Submit button is clicked. 4.1_ (10 pts) The customer login and password must be read from the table CPS3740.Customers. Login and password cannot be hard coded in the program. 4.2_ _ (5 pts)The input login should NOT be case sensitive, but the password should be case sensitive. 4.3_ (5 pts) If the login or password is empty, please show corresponding error messages and exit the program and NOT access the database. If both login and password are not empty, the program should access the table CPS3740. Customers to verify the login and password. 4.4_ (5 pts) If the login does not exist in the database, please display an error message "Login XXXX doesn't exist in the database" and exit the program. 4.5_ (5 pts) If the login exists in the database, but password doesn't match the record in database, please display an error message "login xxxx exists, but password not matches." and exit the program. 5. *(35 pts) Successfully login - If the login and password match the records in the database, your program "login1.php" should do the followings. Please refer to the project 1 main page shown in Figure 4. 5.1_ _(5 pts) Display the customer's name, age, street, city, zipcode. 5.2_ (10 pts) Display customer's IP address and display an message "You are (NOT) from Kean domain." under the IP address, if the customer (NOT) login from Kean domain (10.***) or (131.125.*.*) 5.2 (10 pts) Display all records and all columns in your Money_xxxx table that you created and inserted in Homework1. The results must be aligned using HTML with meaningful headers. 53. (5 nts) If the type is denosit the amount should be shown in blue color. If the tune is withdraw Type here to search 1:22 PM 2/18/2019 5. *(35 pts) Successfully login - If the login and password match the records in the database, your program "login1.php" should do the followings. Please refer to the project 1 main page shown in Figure 4. 5.1 (5 pts) Display the customer's name, age, street, city, zipcode. 5.2_ (10 pts) Display customer's IP address and display an message "You are (NOT) from Kean domain." under the IP address, if the customer (NOT) login from Kean domain (10.**.*) or (131.125.*.*) 5.2_ (10 pts) Display all records and all columns in your Money_xxxx table that you created and inserted in Homework1. The results must be aligned using HTML with meaningful headers. 5.3 (5 pts) If the type is deposit, the amount should be shown in blue color. If the type is withdraw, the amount should be shown in red color. 5.4_ (5 pts) Calculate and display the balance under the table. Your IP: 100.100.100.100 You are NOT from Kean Unversity. Welcome Customer: Austin Huang age: 38 Address: 1000 Morris Ave., Union, 07083 The transcations for customer Austin Huang are: Saving account ID Code Operation Amount Date Time Note 1 xy001 Deposit 4000 2018-12-25 17:10:33 Manually inserted 2 Xy002 Withdraw -2000 2018-12-25 17:10:33 Manually inserted 3 Xy003 Deposit 3000 2018-12-25 17:10:33 Manually inserted 4 xy004 Withdraw |-1000 2018-12-25 17:10:33 Manually inserted Total balance: 4000 Figure 4. Project 1 main page after the customer login successfully 1:21 PM Type here to search