Hi
I have tried a few different "else if" statements and none seem to work how I want.
I have this redirection/login page and if someone enters their email into it the password reminder script it emails the member their password ( that bit works ) but I would like it to print a message to the screen if the email isnt in the db ( strquery==0)?
here is the code:
<?php
//Full URL of redirection file in protected area
//Example: http://www.yourdomain.com/membersonly/redirect.html
$redirect_url = "http://www.xxxxxx.com.au/admin/redirect.html";
//When using htaccess protection it's better to exclude
//some characters from username and password
//Remove tags and special characters
$username = strip_tags($username);
$username = str_replace(",","",$username);
$username = str_replace("\"","'",$username);
$username = str_replace("'","",$username);
$username = str_replace("\\","",$username);
$username = str_replace("\t"," ",$username);
$username = str_replace("/","",$username);
$username = str_replace("*","",$username);
$username = str_replace(">","",$username);
$username = str_replace("<","",$username);
$username = str_replace(":","",$username);
$username = str_replace("|","",$username);
$username=trim($username);
//If email submitted
if($email)
{
include('./include/header.inc');
$cn=mysql_connect($dbhost,$dbuser,$dbpasswd) or die("cannot connect to the server");
$db=mysql_select_db($dbname) or die("cannot connect to the database");
$strqry="select MFname,MLname,MLgName,MLgPasswd,MEmail from TblCpMembers where MEmail='$email'";
mysql_query($strqry);
$res=mysql_query($strqry);
//Im assuming the if result = zero echo would go here?
if ($res)
{
while ($row=mysql_fetch_array($res))
{
$name1=$row["MLgName"];
$email1=$row["MEmail"];
$subject="Alliance - Password Reminder";
$to=$row["MEmail"];
$body="Hello ". $row["MFname"] . " ". $row["MLname"]. "<br><br>Your login details are:<br><br>Login Name: ". $row["MLgName"] . "<br>Password: ". $row["MLgPasswd"]. "";
include('./include/email.inc');
}
}
}
//If password submitted
if($username){
//Remove tags and special characters
$password = strip_tags($password);
$password = str_replace(",","",$password);
$password = str_replace("\"","'",$password);
$password = str_replace("'","",$password);
$password = str_replace("\\","",$password);
$password = str_replace("\t"," ",$password);
$password = str_replace("/","",$password);
$password = str_replace("*","",$password);
$password = str_replace(">","",$password);
$password = str_replace("<","",$password);
$password = str_replace(":","",$password);
$password = str_replace("|","",$password);
$password=trim($password);
//Making sure "http://" part is removed from redirect_url for proper redirection URL assembly
$redirect_url=eregi_replace ("^http://", "", $redirect_url);
//Assembling redirection Javascript function
$redirect_content = "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
<HTML>
<HEAD>
</HEAD>
<SCRIPT language=\"javascript\">
<!-- Begin
function login() {
var username = '$username';
var password = '$password';
var redirect_url = '$redirect_url';
var updated_redirect_url = 'http://' + username + ':' + password + '@' + redirect_url;
window.location = updated_redirect_url;
}
login();
// End -->
</SCRIPT>
<BODY>
</BODY>
</HTML>
";
//When redirection Javascript function is output on screen - user is sent to redirect.html
echo "$redirect_content";
exit;
}//If username submitted end
//Run login form if no username provided
//Ive commented this out coz it was generating a headers error..any ideas why this happens?
//header("Location:login.html");
?>
Thanks
Mark Rendell