I have this php login script which I would like to use with an HTML login page my group mate created.
Now I know from previous post that login should be best handled with just a php script alone, however for the sake of keeping things civil and easy
for group-mate, I would like to know how can I use this php login form with the html form method = "post" action = "".
I am thinking that I should just remove the print '<form action="login.php".....> section of my code but, will that work and is there a better way (other than obviously just using the PHP form alone) to do this.?
I am enclosing my php form first and then my classmates html form second.
Thank you in advance for all your help!
M_M
<?php
//login php
//in theory:use the compare example from the passwords in the register.php file downloaded from the internet and the pull user, store them into two variables and see if the variables match if not, try again.
// connect to database
//basic variables: the database address, SQL username and password, and database name
$config['address'] = 'localhost';
$config['username'] = 'cmpt'; //Can be changed.
$config['password'] = 'ZuvRMpn38FzZcbzz'; //Can be changed If there is a password to the sql database or removed
$config['databasename'] = 'customers'; //can be changed.
$userNameVariable = mysql_query("SELECT uname FROM customers");
$userPasswordVariable = mysql_query("SELECT pword FROM customers");
mysql_connect($config['address'], $config['username'], $config['password']);
mysql_select_db($config['databasename']);
define ('TITLE', 'Login');
print '<h1>Login Form </h1>
<p> Welcome to JAD Computing, please log in to experience the full site, thank you. </p>';
// Check if the form has been submitted:
//try a for loop
//if (isset($_POST['email'])) && (!empty($_post['password'])) ) {
// if ( (strtolower($_POST['email']) == mysql_query("SELECT * FROM customers WHERE username
if ( isset($_POST['submitted']))
{
//Handle the form
if ((!empty($_POST['email'])) && (!empty($_POST['password'])) ) {
if ( (strtolower($_POST['email']) == $userNameVariable ) && ($_POST['password'] == $userPassword)) { //if corect
//Do session stuff:
session_start();
$_SESSION['email'] = $_POST['email'];
$_Session['loggedin'] = time();
//Redirect the user to the welcome page!
ob_end_clean(); //destroy the buffer
header ('Location: welcome.php');
exist();
} else { // If incorrect!
print '<p> The submitted email address and password do not match those on file! <br /> Go back and try again</p>';
}
} else { //Forgot a field.
print '<p>Please make sure you enter both an email address and a password! <br /> Go back and try again.</p>';
}
} else { //Display the form for testing reasons.
print '<form action="login.php" method="post">
<p>Email Address: <input type="text" name="email" size="20" /></p>
<p>Password: <input type="password" name="password" size="20" /></p>
<p><input type="submit" name="submit" value="Log In!" /></p>
<input type="hidden" name="submitted" value="true" />
</form>';
}
?>
html form
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title> J.A.D. Computing Login Page </title>
<!-- This page will serve as the login page for the website -->
<!-- If a user has an account they will enter their login name and pass -->
<!-- word, and if they don't they have the option to register for one -->
<!-- It should be noted that only registered users can access the entire -->
<!-- website. -->
</head>
<style type="text/css">
.vert {background-image: url(computer.jpg); background-repeat: repeat-y;background-position: right;}
a:hover {background-color:pink}
</style>
<body bgcolor = 'silver' class = "vert">
<center>
<h1> Welcome to JAD Computing </h1>
<h4> Please Log in Below </h4>
<form method = "post" action = " " >
<p>
User Name: <input type="text" name="UserName" onfocus="this.style.background='#ff0000'" onblur="this.style.background='#00ffff'" size=�25� id="UserName" />
<br />
Password: <input type = "password" name="password" onfocus="this.style.background='#FF0000'" onblur="this.style.background='#FF00FF'" size=�25� id="Password" />
<br />
<input type = "submit" value = "Submit" /> <input type = "reset" value = "Reset" />
<br />
</p>
</center>
</form>
<form method = "post" action = "delete.php " >
<p>
Last Name <input type="text" name="LastName" size=�25� id="LastName" />
<br /> <input type = "submit" value = "Submit" /> <input type = "reset" value = "Reset" />
</p>
<p>
<br />
<br />
</p>
</form>
<center>
<h4>New Users, create account below </h4>
<form method="post" action="registration2.php" >
Firstname: <input type="text" name="firstname" /> <br />
Lastname: <input type="text" name="lastname" /> <br />
User Name: <input type="text" name="uname" /> <br />
Password: <input type="password" name="pword" /> <br />
Street Address: <input type="text" name="street" /> <br />
City: <input type="text" name="city" /> <br />
State: <input type="text" name="state" /> <br />
Zip Code: <input type="text" name="zip" /> <br />
<input type="submit" />
</form>
</center>
</body>
</html>

New Topic/Question
Reply



MultiQuote




|