N
Nik Saprano
Ребят, помогите вот с чем:
Ниже приведен код, который осуществляет вход юзера на сайт.
Для входа используется логин и пароль. Нужно, чтобы юзер вводил при входе вместо логина свой имэйл, который он указал при регистрации.
<?
session_start();
include "affconfig.php";
include "lang/$language";
if ($_POST['userid']!='' && $_POST['password']!='')
{
// protection against script injection
$userid = preg_replace('/[^a-zA-Z0-9_]/', '', $_POST['userid']);
$password = preg_replace('/[^a-zA-Z0-9_]/', '', $_POST['password']);
// if the user has just tried to log in
$db_conn = mysql_connect($server, $db_user, $db_pass) or die ("Database CONNECT Error (line 11)");
mysql_select_db($database, $db_conn);
$query = "select * from affiliates where refid='$userid' and pass='$password'";
$result = mysql_query($query, $db_conn);
$id = mysql_fetch_array($result);
if (mysql_num_rows($result) > 0)
{
$_SESSION['id'] = $id['id'];
// if they are in the database register the user id
$_SESSION['aff_valid_user'] = $userid;
// logout admin if he was logged in before
$_SESSION['aff_valid_admin'] = '';
unset($_SESSION['aff_valid_admin']);
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=0;URL=members_only.php>";
exit;
}
}
if(aff_check_security())
{
aff_redirect('members_only.php');
exit;
}
else
{
if (isset($_POST['userid']))
{
// if they've tried and failed to log in
echo AFF_I_CANNOTLOG;
}
// else
// {
// they have not tried to log in yet or have logged out
// echo AFF_I_NOTLOGGED;
// }
// provide form to log in
?>
<form method=post action="index.php">
<tr><td width="70" style="padding-left:20px"><b class="text_3"><?=AFF_G_AFFID?>:</b></td><td colspan="2" style="padding-bottom:5px"><input type=text name=userid style="width:130px; height:21px"></td></tr>
<tr><td width="70" style="padding-left:20px"><b class="text_3"><?=AFF_G_PASSWORD?>:</b></td><td><input type=password name=password style="width:100px; height:21px"> <input class=text_5 name="submit" type="submit" value="OK" style="width:27px; height:23px"></td></tr>
<tr><td colspan="2" height="16"></td></tr>
</form>
<?
}
?>
Ниже приведен код, который осуществляет вход юзера на сайт.
Для входа используется логин и пароль. Нужно, чтобы юзер вводил при входе вместо логина свой имэйл, который он указал при регистрации.
<?
session_start();
include "affconfig.php";
include "lang/$language";
if ($_POST['userid']!='' && $_POST['password']!='')
{
// protection against script injection
$userid = preg_replace('/[^a-zA-Z0-9_]/', '', $_POST['userid']);
$password = preg_replace('/[^a-zA-Z0-9_]/', '', $_POST['password']);
// if the user has just tried to log in
$db_conn = mysql_connect($server, $db_user, $db_pass) or die ("Database CONNECT Error (line 11)");
mysql_select_db($database, $db_conn);
$query = "select * from affiliates where refid='$userid' and pass='$password'";
$result = mysql_query($query, $db_conn);
$id = mysql_fetch_array($result);
if (mysql_num_rows($result) > 0)
{
$_SESSION['id'] = $id['id'];
// if they are in the database register the user id
$_SESSION['aff_valid_user'] = $userid;
// logout admin if he was logged in before
$_SESSION['aff_valid_admin'] = '';
unset($_SESSION['aff_valid_admin']);
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=0;URL=members_only.php>";
exit;
}
}
if(aff_check_security())
{
aff_redirect('members_only.php');
exit;
}
else
{
if (isset($_POST['userid']))
{
// if they've tried and failed to log in
echo AFF_I_CANNOTLOG;
}
// else
// {
// they have not tried to log in yet or have logged out
// echo AFF_I_NOTLOGGED;
// }
// provide form to log in
?>
<form method=post action="index.php">
<tr><td width="70" style="padding-left:20px"><b class="text_3"><?=AFF_G_AFFID?>:</b></td><td colspan="2" style="padding-bottom:5px"><input type=text name=userid style="width:130px; height:21px"></td></tr>
<tr><td width="70" style="padding-left:20px"><b class="text_3"><?=AFF_G_PASSWORD?>:</b></td><td><input type=password name=password style="width:100px; height:21px"> <input class=text_5 name="submit" type="submit" value="OK" style="width:27px; height:23px"></td></tr>
<tr><td colspan="2" height="16"></td></tr>
</form>
<?
}
?>