cvs: php-hosts-web / login.php /include shared.inc
| From: | jim winstead | Date: | Mon, 22 Apr 2002 03:04:13 +0000 |
| Subject: | cvs: php-hosts-web / login.php /include shared.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-9754@lists.php.net to get a copy of this message | ||
jimw Sun Apr 21 23:04:13 2002 EDT
Added files:
/php-hosts-web login.php
Modified files:
/php-hosts-web/include shared.inc
Log:
login page (not that you can do anything once logged in...)
Index: php-hosts-web/include/shared.inc
diff -u php-hosts-web/include/shared.inc:1.7 php-hosts-web/include/shared.inc:1.8
--- php-hosts-web/include/shared.inc:1.7 Sun Apr 21 21:36:09 2002
+++ php-hosts-web/include/shared.inc Sun Apr 21 23:04:13 2002
@@ -3,6 +3,9 @@
require 'country_codes.inc';
+/* let caches know that we vary page content based on Cookie headers. */
+header("Vary: Cookie");
+
mysql_pconnect("localhost", "nobody")
or die("unable to connect to database: ".mysql_error());
@@ -19,7 +22,6 @@
$BOOLEAN[0] = "No";
$BOOLEAN[1] = "Yes";
-
function mysql_get_one($query) {
$res = mysql_query($query);
if ($res && mysql_num_rows($res)) {
@@ -88,4 +90,19 @@
require("layout.inc");
+function display_errors($errors) {
+ echo '<div class="errors">';
+ if (count($errors) > 1) {
+ echo "You need to do the following before your submission will be accepted:<ul>";
+ foreach ($errors as $error) {
+ echo "<li>$error</li>\n";
+ }
+ echo "</ul>";
+ }
+ else {
+ echo $errors[0];
+ }
+ echo '</div>';
+}
+
?>
Index: php-hosts-web/login.php
+++ php-hosts-web/login.php
<?php
require 'shared.inc';
$errors = array();
if ($in) {
if (!$in['email']) {
$errors[] = "You have to specify the mail address you'd like to log in as.";
}
if (!$in['pass']) {
$errors[] = "You need to supply your password to log in.";
}
if (!$errors) {
$id = mysql_get_one("SELECT HostId FROM users WHERE UserEmail='$in[email]' AND
ENCRYPT('$in[pass]',UserPass) = UserPass");
if ($id) {
setcookie("HOSTID","$id:".base64_encode($in['pass']));
header("Location: showinfo.php?hostid=$id&login=1");
exit;
}
else {
$errors[] = "The account information you supplied is not correct.";
}
}
}
commonHeader("Login");
if ($errors) {
display_errors($errors);
}
else {?>
<div class="explain">
If you submitted information about a company, this is where you can log in to
edit your entry. The email address to use is the contact address you used when
first telling us about your company. That's where we sent the email with your
password. You may have also signed up for a specific username that you used to
log in. That's no longer required. All that's used now is your email address.
</div>
<?php
}
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<table>
<tr>
<th align="right">Email address:</th>
<td><input type="text" name="in[email]" size="40"
maxlength="64" value="" />
</tr>
<tr>
<th align="right">Password:</th>
<td><input type="password" name="in[pass]" size="16" />
</tr>
<tr>
<td align="right"><input type="submit" value="Log in"
/></td>
</tr>
</table>
</form>
<?php
commonFooter();
?>