Permalink
Browse files

code cleanup

  • Loading branch information...
1 parent e6c3459 commit b5c619543d2e7bc4325ddab52deb4b352c0e726a @wwalser wwalser committed Dec 8, 2010
Showing with 21 additions and 33 deletions.
  1. +9 −13 demos/index.php
  2. +7 −6 demos/static/style.css
  3. +5 −1 demos/templates/demo.php
  4. +0 −13 demos/templates/success.php
View
@@ -24,23 +24,19 @@ function validateIndex(){
);
}
-if ($_POST['validate']) {
- unset($_POST['validate']);
- $oValidation = new Validation($oRequest);
- $aErrors = $oValidation->validate(validateIndex(), $_POST);
- if (empty($aErrors)){
- // process account registration
- $aErrors['valid'] = true;
- $aErrors['global'] = 'You have successfully registered an account with MacGuffin App!';
- }
- echo json_encode($aErrors);
- exit(0);
-} else if ($_POST) {
+
+if ($_POST) {
$oValidation = new Validation($oRequest);
$aErrors = $oValidation->validate(validateIndex(), $_POST);
if (empty($aErrors)) {
// process account registration
- include('templates/success.php');
+ $aErrors['valid'] = true;
+ $aErrors['global'] = 'You have successfully registered an account with MacGuffin App!';
+ $aErrors['details'][] = 'Take this time to celebrate.';
+ }
+
+ if ($_POST['validate']) {
+ echo json_encode($aErrors);
exit(0);
}
}
@@ -1,15 +1,15 @@
body{
width:955px;
margin:0px auto;
-}
+ }
-.validationSuccess{
+#messageBox{
display: none;
-}
+ }
-.validationFailure{
- display: block;
+#messageBox.validationFailure{
border: 2px solid #F6D10A;
+ display: block;
margin: 20px 0;
padding:0 15px;
@@ -25,8 +25,9 @@ body{
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#D6D1CA', EndColorStr='#ffffff');
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#D6D1CA', EndColorStr='#ffffff')";
}
-.successMessage{
+#messageBox.successMessage{
border: 2px solid #709900;
+ display: block;
margin: 20px 0;
padding:0 15px;
@@ -8,7 +8,7 @@
<body>
<h1>MacGuffin App *beta</h1>
<p>Register for an account (doesn't actually save any data).</p>
- <div id="messageBox" class=<?php if (!empty($aErrors)) {echo '"validationFailure"';} else {echo '"validationSuccess"';} ?> >
+ <div id="messageBox" class="<?php if ($aErrors['valid']) {echo 'successMessage';} else if (!empty($aErrors)) {echo 'validationFailure';}?>" >
<?php
if (!empty($aErrors)) {
echo '<p>' . $aErrors['global'] . '</p>';
@@ -18,6 +18,9 @@
}
?>
</div>
+ <?php
+ if (empty($aErrors) || !$aErrors['valid']) {
+ ?>
<form method="post" id="" action="">
<label for="email" name="email">Email:</label>
<input type="text" name="email" input="email" /><br />
@@ -27,5 +30,6 @@
<input type="password" name="password" input="password" /><br />
<input class="submit" type="submit" name="submit" input="submit" value="Create My Account" />
</form>
+ <?php } ?>
</body>
</html>
@@ -1,13 +0,0 @@
-<!DOCTYPE html>
-<html>
- <head>
- <link rel="stylesheet" type="text/css" media="all" href="style.css">
- <script charset="utf-8" src="jquery-1.4.4.min.js"></script>
- <script charset="utf-8" src="validation.js"></script>
- </head>
- <body>
- <h1>MacGuffin App *beta</h1>
- <p>Register for an account (doesn't actually save any data).</p>
- <div id="messageBox" class="successMessage"><p>You have successfully registered an account with MacGuffin App!</p></div>
- </body>
-</html>

0 comments on commit b5c6195

Please sign in to comment.