Forum Moderators: coopster

Message Too Old, No Replies

Trying to find a script for member log in

         

kentuckyslone

1:39 am on Jun 1, 2005 (gmt 0)

10+ Year Member



I need a script that will allow a user to enter ID and password and then be directed to their own unique page.

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

ramoneguru

6:57 am on Jun 1, 2005 (gmt 0)

10+ Year Member



I'm not sure on the redirecting to a members own unique page, I remember a similar thread though. Try looking in here and you might find it. Hope ergophobe doesn't kiil me for posting this much code. I'm not sure if this is a "do my homework" thread, but I'll still try and help. After all, we're not sourceforge over here :) Modify it where you feel the need. Its a little obfuscated, but does the job I suppose.

<?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 "&nbsp;</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\"> &nbsp; <br>\n";

print "Password: <input type=\"password\" name=\"password\" size=\"20\"> &nbsp; <br><br>\n";

print "<input type=\"submit\" name=\"submit\" value=\"login\"> &nbsp; </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 &copy; 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\" >&nbsp;<b> Please enter your email address and password to log in!</b> <br/></font>";
print "<font color =\"#000099\">&nbsp; <b>Not sure where to start? Check out the links below.</b> </font>";

getLogin2();
}

?>

</body>
</html>


--Nick

electricocean

4:50 am on Jun 2, 2005 (gmt 0)

10+ Year Member




login page:

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{