How do I add a password checker, so that the php checks the e-mail and
password combo, and if not correct, does not allow user into the site?
Using a pop up java window to frame the php scripts. Following is the
portion of the script checking the email, and allowin subscribe /
unsubscribe, etc., but not sure how to check password used as well, and
then if not correct combo, close the main window.

<?php

// connect to db
$db = mysql_connect("xxxx","yyy") or die ("Couldn't connect.");

mysql_select_db("xxx", $db) or die ("Couldn't select db.");

// get a date stamp
$add_date = date("Y-m-d H:i:s");

if ($op != "ds") {

        //they need to subscribe or unsubscribe

        $text_block = "

<form name=\"form\" method=post action =\"subscribe.phtml\">
<input type=hidden name=op value =ds>

<p><strong>Enter Your e-Mail Address. This is / will be your User
Name:</strong><br>
<input type=text name=\"email\" size=25></p>
<p><strong>Enter a Password.</strong><br>
<input type=password name=\"password\" size=25></p>


<p><strong>Click your selection:</strong><br>
<input type=radio name=\"action\" value=\"sub\" checked> Subscribe
<input type=radio name=\"action\" value=\"unsub\"> Unsubscribe</p>

<p><input type=submit name=\"submit\" value=\"Enter or Subscribe /
Unsubscribe Now\"></p>
</form>

";

}

else if (($op == "ds") && ($action == "sub")) {

// check they're not already subscribed
// then subscribe them or return message

$check = "select email from subscribe
        where email = \"$email\"";

$check_result = mysql_query($check)
        or die("Can't execute check email address.");

$check_num = mysql_num_rows($check_result);

if ($check_num == 0) {

        // if $check_num is 0, then no match was found,
        // and the user should be subscribed

        $sql = "insert into subscribe (email, password, add_date,
sub_id) values(\"$email\", \"$password\", \"$
add_date\", \"\")";

        @mysql_query($sql) or die ("Couldn't insert email.");

        $text_block = "
        <p><h1><center><font color=green>Thanks for Joining
</h1></center></font></p>
        ";

} else {

        // if $check_num is not 0, then the user is
        // already subscribed, and let them know it.

        $text_block = "
        <p><font color=green><b>You are a recognized member of the
database. Please enjoy yourself. If you need
 anything, please e-Mail us at <a href=\"mailto:.com\">info@.com</a>
 Thank you!</b></font></p>
        ";

        }
}

else if (($op == "ds") && ($action == "unsub")) {

        // check they're already subscribed,
        // then unsubscribe them or return message.

$check = "select email from subscribe
        where email = \"$email\"";

$check_result = mysql_query($check)
        or die("Can't execute check e-mail address.");

$check_num = mysql_num_rows($check_result);

if ($check_num == 0) {

        // if $check_num is 0, then no match is found,
        // and the user cannot be unsubscribed

        $text_block = "
        <p><font color=red><b>Couldn't find your e-mail / user name on
the list.</b></font></p>
        <p><i>You haven't been unsubscribed because the e-Mail you
entered is not in
        the database.</i>";

}  else {

        // if $check_num is not 0, then the user is on the list, so can
be unsubscribed.

        $sql = "delete from subscribe
                where email = \"$email\"";

        @mysql_query($sql) or die ("Couldn't delete email.");

        $text_block = "
        <p><font color=black><b> You are unsubscribed from the
Database!<i> Hope to see you back soon!</i></b></font></p>
        ";
                }
}

?>

<html>
<head>
<title>Form: Join the Database / username - password</title>
</head>
<body>

<h2><font color=red><center>Input your e-Mail and password to
enter.</font><br><font color=blue> Use this Form
to Subscribe / Unsubscribe<br> to the <br>
Database.</center></font></h2>

<?php echo "$text_block";  ?>

</body>
</html>

--
Marc S. Bragg
[EMAIL PROTECTED]
Bialecki & Bragg, PC
p: 610-444-7508
f: 610-444-7548

http://www.chescolawyers.com/BB
"Chester County Legal Services" - "For All Your Legal Needs"


http://www.bloody100th.com "WWII 101st Airborne Division"
http://www.petercatalano.com "Soul of An Italian Artist"



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to