Forum Moderators: coopster
All the scripts I have looked at will send the user to a secured page but I havent found a way to send each individual to a different page dependng upon the info they enter.
I am hoping to find a free script or at least one that is low cost.
David
<?php
session_start();
include('dbconnect.php'); //connect to your own database of course
function getLogin()
{
print "<HTML><HEAD><TITLE> Login </TITLE><link rel=\"stylesheet\" type=\"text/css\" href=\"mystyle.css\" /></HEAD><BODY>";
print "<table width=\"520\" bgcolor=\"#ccccff\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\" height=\"400\" >\n";
print "<tr> <!------------------Top Navigation (Title)-------------->\n";
print "<form action=\"login.php\" method=\"POST\" name=\"login\">\n";
print "<td width=\"180\">\n";
print" <img src=\"images/head.gif\"> </td>\n";
print"<td width=\"340\"><h3><center>Your Company Name Here </center></H3></td></tr>\n";
print"<tr><td width=\"520\" bgcolor=\"ccccff\" colspan=\"2\" align=\"center\" border=\"0\" >\n";
print "<hr size=\"2\" width=\"70%\"><br></td>\n";
print "</tr>\n";
print "<tr><td colspan=\"2\" bgcolor=\"#ccccff\" width=\"580\" height=\"30\" align=\"left\" border=\"1\">";
}
function getLogin2()
{
print " </td></tr>";
print "<td colspan=\"2\" bgcolor=\"#ccccff\" width=\"480\" align=\"right\">\n";
print "Email Address: <input type=\"text\" size=\"20\" name=\"email\" value = \"{$_POST['email']}\" size=\"13\"> <br>\n";
print "Password: <input type=\"password\" name=\"password\" size=\"20\"> <br><br>\n";
print "<input type=\"submit\" name=\"submit\" value=\"login\"> </td></tr><br><br>\n";
print "</td></tr>\n";
print "<tr><td td colspan=\"2\" align=\"center\"><hr width=\"60%\" size=\"1\" noshade></td></tr>";
print "<tr><td td colspan=\"2\" align=\"center\"><font size=\"-2\" face=\"arial\" color=\"#8d8d8d\"> ";
print "Copyright © 2005 ramoneguru. All rights reserved. </font></td></tr></center>";
print "</table>\n";
}//end getLogin
if (isset ($_POST['submit']))//check to see if submit button is pressed
{
$tempEmail = $_POST[email];
$tempPass = $_POST[password];
if( validate_email($tempEmail)) //check if email has correct form, so do your own error checking
{
//getUsernamePassword is a function you'll have to write yourself.
//Just connect to your database and check to see if the username and password line up
if (getUsernamePassword($tempEmail, $tempPass))//if email belongs to user, send to member page
{
$_SESSION['login'] = "logged member";
$_SESSION['sessionEmail'] = $_POST['email'];
$_SESSION['sessionId'] = "$tempId";
header("Location: memberHome.php");
}
elseif(getOrganizationnamePassword($tempEmail, $password, &$tempId))//if email belongs to organization, send to organization page
{
$_SESSION['orglogin'] = "logged organization";
$_SESSION['sessionEmail'] = $_POST['email'];
$_SESSION['sessionId'] = "$tempId";
//why not set a session varialble equal to individualID, since it'll never be updated
header("Location: orgHome.php");
}
else //email is not stored in database
{
getLogin();
print "<p><b><font color=\"red\"> Login Failed!<br></b> \n";
echo "<b>\" {$_POST['email']} \"</b> and <b>Your Password</b> do not match our records!<br/>";
echo "Please make sure you are inputting them correctly.</font></p>\n";
getLogin2();
}
}
else
{
getLogin();
print "<p><b><font color=\"red\"> Login Failed!</b><br>\n";
echo "\"<b> {$_POST['email']} \"</b> is not a valid email!<br/>";
echo "Make sure you are using a valid email address with a valid domain</font></p>\n";
getLogin2();
}
}
else
{
getLogin();
print "<font color =\"#000099\" > <b> Please enter your email address and password to log in!</b> <br/></font>";
print "<font color =\"#000099\"> <b>Not sure where to start? Check out the links below.</b> </font>";
getLogin2();
}
?>
</body>
</html>
--Nick
if (//all is good
){
session_start();
$_SESSION['username'] = $username; //or w/e you username variable is.
$redirect_url = //url of file to
header("Location: $redirect_url");
}
else{
print "<font color=\"red\" size=\"+1\">Sorry, wrong login information.</font>";
}
othr pages:
session_start();
header("Cache-control: private");
if (!isset($_SESSION['username']) ¦¦ empty($_SESSION['username'])) {
$login_url = //login page
header("Location: $login_url");
exit;
}
else{