Implement login form, and make some minor style changes

master
Sven Slootweg 12 years ago
parent b5bc476e08
commit 89dffba731

@ -0,0 +1,51 @@
<?php
/*
* ReDonate is more free software. It is licensed under the WTFPL, which
* allows you to do pretty much anything with it, without having to
* ask permission. Commercial use is allowed, and no attribution is
* required. We do politely request that you share your modifications
* to benefit other developers, but you are under no enforced
* obligation to do so :)
*
* Please read the accompanying LICENSE document for the full WTFPL
* licensing text.
*/
if(!isset($_APP)) { die("Unauthorized."); }
$sError = "";
if(!empty($_POST['submit']))
{
if(empty($_POST['username']))
{
$sError = "You did not enter a username.";
}
elseif(empty($_POST['password']))
{
$sError = "You did not enter a password.";
}
else
{
try
{
$sUser = User::CreateFromQuery("SELECT * FROM users WHERE `Username` = :Username", array(":Username" => $_POST['username']), 0, true);
if($sUser->VerifyPassword($_POST['password']))
{
$sUser->Authenticate();
redirect("/dashboard");
}
else
{
$sError = "The password you entered is incorrect. Did you <a href=\"/forgot-password\">forget your password</a>?";
}
}
catch (NotFoundException $e)
{
$sError = "That username does not exist.";
}
}
}
$sPageContents = NewTemplater::Render("login/form", $locale->strings, array('error' => $sError));

@ -145,6 +145,17 @@ pre.debug
* FORMS *
**************************************/
.formwrapper
{
width: 485px;
margin: 0px auto;
}
.formwrapper.narrow
{
width: 432px;
}
.formfield
{
margin: 6px 0px;
@ -169,7 +180,7 @@ pre.debug
{
font-size: 17px;
padding: 4px;
width: 30%;
width: 270px;
border: 1px solid #6CA825;
border-radius: 1px;
background-color: #F4FDE4;
@ -177,24 +188,34 @@ pre.debug
.formfield label
{
width: 18%;
width: 170px;
font-size: 18px;
padding-top: 7px;
margin-right: 12px;
font-weight: bold;
}
form.narrow .formfield label
{
width: 130px;
}
.formfield.submit
{
padding-left: 20%;
padding-left: 182px;
margin-top: 24px;
}
form.narrow .formfield.submit
{
padding-left: 142px;
}
form .note
{
clear: both;
font-size: 14px;
margin-left: 20%;
margin-left: 182px;
padding-top: 3px;
}
@ -204,10 +225,54 @@ form .note:before
margin-right: 5px;
}
form button
{
margin-top: 0px;
background: #61AF12;
border-top: 1px solid #529d26;
border-right: 1px solid #2c5615;
border-bottom: 1px solid #1d390e;
border-left: 1px solid #2c5615;
border-radius: 4px;
box-shadow: inset 0 1px 10px 1px #6CDD28,
0px 1px 0 #2c5713,
0 2px 0px #305e14,
0 3px 2px 1px #111111;
color: #fff;
font: bold 17px/1 "helvetica neue",
helvetica,
arial,
sans-serif;
margin-bottom: 15px;
padding: 10px 19px 12px 19px;
text-align: center;
text-shadow: 0px -1px 1px #1e2d4d;
-webkit-background-clip: padding-box;
}
form button:hover
{
box-shadow: inset 0 0px 20px 1px #75DB38,
0px 1px 0 #324d1d,
0 2px 0px #37531f,
0 3px 2px 1px #111111;
cursor: pointer;
}
form button:active
{
box-shadow: inset 0 1px 10px 1px #85BC59,
0 1px 0 #203213,
0 2px 0 #223413,
0 3px 3px 0 #111111;
margin-top: 2px;
margin-bottom: 13px;
}
.errors
{
color: #2F0003;
margin-bottom: 36px;
margin-bottom: 30px;
padding: 12px;
border: 1px solid #6F0008;
background-color: #FFF7F8;

@ -0,0 +1,27 @@
<div class="formwrapper narrow">
<h2 class="spaced">Login to your account</h2>
{%if isempty|error == false}
<div class="errors">
{%?error}
</div>
{%/if}
<form method="post" action="/login" class="narrow">
<div class="formfield">
<label>Username</label>
{%input type="text" name="username"}
<div class="clear"></div>
</div>
<div class="formfield">
<label>Password</label>
{%input type="password" name="password"}
<div class="clear"></div>
</div>
<div class="formfield submit">
<button type="submit" name="submit" value="submit">Login</button>
</div>
</form>
</div>

@ -1,49 +1,51 @@
<h2 class="spaced">Great! It'll only take a moment...</h2>
<div class="formwrapper">
<h2 class="spaced">Great! It'll only take a moment...</h2>
{%if isempty|errors == false}
<div class="errors">
One or more problems occurred:
<ul>
{%foreach error in errors}
<li>{%?error}</li>
{%/foreach}
</ul>
Please correct these issues and submit the form again.
</div>
{%/if}
{%if isempty|errors == false}
<div class="errors">
One or more problems occurred:
<ul>
{%foreach error in errors}
<li>{%?error}</li>
{%/foreach}
</ul>
Please correct these issues and submit the form again.
</div>
{%/if}
<form method="post" action="/sign-up">
<div class="formfield next-similar">
<label>Username</label>
{%input type="text" name="username"}
<div class="clear"></div>
</div>
<form method="post" action="/sign-up">
<div class="formfield next-similar">
<label>Username</label>
{%input type="text" name="username"}
<div class="clear"></div>
</div>
<div class="formfield next-similar previous-similar">
<label>Name (optional)</label>
{%input type="text" name="displayname"}
<div class="clear"></div>
</div>
<div class="formfield next-similar previous-similar">
<label>Name (optional)</label>
{%input type="text" name="displayname"}
<div class="clear"></div>
</div>
<div class="formfield previous-similar">
<label>E-mail address</label>
{%input type="email" name="email"}
<div class="note">we'll send you a verification e-mail</div>
</div>
<div class="formfield previous-similar">
<label>E-mail address</label>
{%input type="email" name="email"}
<div class="note">we'll send you a verification e-mail</div>
</div>
<div class="formfield next-similar">
<label>Password</label>
{%input type="password" name="password"}
<div class="clear"></div>
</div>
<div class="formfield next-similar">
<label>Password</label>
{%input type="password" name="password"}
<div class="clear"></div>
</div>
<div class="formfield previous-similar">
<label>Password (again)</label>
{%input type="password" name="password2"}
<div class="note">at least 8 characters</div>
</div>
<div class="formfield submit">
<button type="submit" class="green-button" name="submit" value="submit">Sign me up!</button>
</div>
</form>
<div class="formfield previous-similar">
<label>Password (again)</label>
{%input type="password" name="password2"}
<div class="note">at least 8 characters</div>
</div>
<div class="formfield submit">
<button type="submit" class="green-button" name="submit" value="submit">Sign me up!</button>
</div>
</form>
</div>

Loading…
Cancel
Save