Hello, I am having trouble doing this assignment. Its seems to wordy because it
ID: 3551543 • Letter: H
Question
Hello, I am having trouble doing this assignment. Its seems to wordy because it explains what exactly to do. So, please help me to answer these questions. If anyone willing to help then please be organized so that I understand it clearly. You can either answer it below or save the php files as it says in instructions. Either works for me.
Help will be greatly appreciated. Thank you in advance!
At the root of your application, createa folder called login. Inside the login folder,create a PHP file named index.php.
The index.php file will containa login form that acceptsa username and password. The actionof the form should go to process_login.php.
Each field on the login form shouldhave a <label>tag, an <input>tag,and a <div>tag that can display an error message. The form shouldalso have a submit button.
You will validate the form using JavaScript and PHP.
Create a login.jsfile
Using the folderstructure provided to you as a guide,create a file called login.js
Connect the login.js file to the login/index.php file.
Using JavaScript, createan event listenerfor the blur method of each <input>field. If the field is empty, display an error to the user and changethe color of the field
Explanation / Answer
/* just create a table in database with name userinfo. take username,password as attributes. it will validate from that. gud approach. */
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if(!empty($_POST['username']) && !empty($_POST['password']))
{
if(($_POST['username']=='hardeep') && ($_POST['password']=='admin'))
{
session_start();
$_SESSION['name']=$_POST['username'];
header('location:show1.php');
}
else
{
$con= mysqli_connect('localhost','root','','school');
$result=mysqli_query($con,"select username,password from userinfo");
while($value=mysqli_fetch_array($result,MYSQL_ASSOC))
{
if(($_POST['username']==$value['username']) && ($_POST['password']==$value['password']))
{
session_start();
$_SESSION['name']=$_POST['username'];
header('location:show.php');
}
}
mysqli_close($con);
}
}
}
else
{
echo " please enter username and password";
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="loginbutton.css" />
<style type="text/css">
a{
float:right;
font-size:20px;
}
</style>
</head>
<body background="1.jpg">
<div id="top">
<center>Welcome to Rapidsoft Technology Pvt. Ltd</center>
</div>
<center>
<div id="container">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
<label for="username">Username:<span>*</span></label>
<input type="text" id="username" name="username" required><br />
<label for="password">Password:<span>*</span></label>
<input type="password" id="password" name="password" required>
<div id="lower">
<input type="submit" value="Login" id="bt1" />
<input type="reset" value="Reset" id="bt2" /><br />
<a href=".Assi71.php"> SignUp</a>
</div>
</form>
</div>
</center>
<div id="leftmar">
<marquee direction="down" id="down"><img src="group.jpg" height="500px" width="500px" /></marquee>
</div>
<footer id="foot"> <marquee behavior="alternate" >Hardeep Singh</marquee></footer>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.