signup page converted
This commit is contained in:
parent
6a38fab536
commit
16037222e2
2 changed files with 157 additions and 137 deletions
159
src/signup.php
159
src/signup.php
|
@ -17,8 +17,6 @@ include("config.php");
|
||||||
include("db.php");
|
include("db.php");
|
||||||
include("funcLib.php");
|
include("funcLib.php");
|
||||||
|
|
||||||
$error = "";
|
|
||||||
|
|
||||||
if (isset($_POST["action"])) {
|
if (isset($_POST["action"])) {
|
||||||
if ($_POST["action"] == "signup") {
|
if ($_POST["action"] == "signup") {
|
||||||
$username = $_POST["username"];
|
$username = $_POST["username"];
|
||||||
|
@ -93,141 +91,28 @@ if (isset($_POST["action"])) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
|
|
||||||
?>
|
$query = "SELECT familyid, familyname FROM {$OPT["table_prefix"]}families ORDER BY familyname";
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
|
$rs = mysql_query($query) or die("Could not query: " . mysql_error());
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
$families = array();
|
||||||
<head>
|
while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
|
||||||
<title>Gift Registry - Sign Up</title>
|
$families[] = $row;
|
||||||
<link href="styles.css" type="text/css" rel="stylesheet" />
|
|
||||||
<script language="JavaScript" type="text/javascript">
|
|
||||||
function validateSignup() {
|
|
||||||
field = document.signup.username;
|
|
||||||
if (field == null || field == undefined || !field.value.match("\\S")) {
|
|
||||||
alert("You must supply a username.");
|
|
||||||
field.focus();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
field = document.signup.fullname;
|
|
||||||
if (field == null || field == undefined || !field.value.match("\\S")) {
|
|
||||||
alert("You must supply your full name.");
|
|
||||||
field.focus();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
field = document.signup.email;
|
|
||||||
if (!field.value.match("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")) {
|
|
||||||
alert("The e-mail address '" + field.value + "' is not a valid address.");
|
|
||||||
field.focus();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<?php
|
|
||||||
if (isset($_POST["action"]) && $_POST["action"] == "signup" && $error == "") {
|
|
||||||
// success!
|
|
||||||
?>
|
|
||||||
<p>
|
|
||||||
Thank you for signing up.
|
|
||||||
</p>
|
|
||||||
<?php
|
|
||||||
if ($OPT["newuser_requires_approval"])
|
|
||||||
echo "<p>The administrators have been informed of your request and you will receive an e-mail once they've made a decision.</p>";
|
|
||||||
else
|
|
||||||
echo "<p>Shortly, you will receive an e-mail with your initial password.</p>";
|
|
||||||
echo "<p>Once you've received your password, click <a href=\"login.php\">here</a> to login.</p>";
|
|
||||||
}
|
}
|
||||||
else {
|
mysql_free_result($rs);
|
||||||
?>
|
|
||||||
<form name="signup" method="post" action="signup.php">
|
define('SMARTY_DIR',str_replace("\\","/",getcwd()).'/includes/Smarty-3.1.12/libs/');
|
||||||
<input type="hidden" name="action" value="signup">
|
require_once(SMARTY_DIR . 'Smarty.class.php');
|
||||||
<div align="center">
|
$smarty = new Smarty();
|
||||||
<table cellpadding="3" class="partbox" width="50%">
|
$smarty->assign('families', $families);
|
||||||
<tr>
|
$smarty->assign('username', $username);
|
||||||
<td colspan="2" class="partboxtitle" align="center">Sign Up for the Gift Registry</td>
|
$smarty->assign('fullname', $fullname);
|
||||||
</tr>
|
$smarty->assign('email', $email);
|
||||||
<tr>
|
$smarty->assign('familyid', $familyid);
|
||||||
<td colspan="2">
|
$smarty->assign('action', $_POST["action"]);
|
||||||
<p>
|
if (isset($error)) {
|
||||||
Complete the form below and click Submit.
|
$smarty->assign('error', $error);
|
||||||
</p>
|
|
||||||
<?php
|
|
||||||
if ($OPT["newuser_requires_approval"]) {
|
|
||||||
?>
|
|
||||||
<p>
|
|
||||||
The list administrators will be notified of your request by e-mail and will approve or decline your request.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
If the e-mail address you supply is valid, you will be notified once a decision is made.
|
|
||||||
</p>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
?>
|
|
||||||
<p>
|
|
||||||
If the e-mail address you supply is valid,
|
|
||||||
you will shortly receive an e-mail with your
|
|
||||||
initial password.
|
|
||||||
</p>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
if ($error != "")
|
|
||||||
echo "<div class=\"message\">" . $error . "</div>";
|
|
||||||
?>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td width="25%">Username</td>
|
|
||||||
<td>
|
|
||||||
<input name="username" size="20" maxlength="20" type="text" value="<?php if (isset($_POST["username"])) echo htmlspecialchars(stripslashes($_POST["username"])); ?>"/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Full name</td>
|
|
||||||
<td>
|
|
||||||
<input name="fullname" size="30" maxlength="50" type="text" value="<?php if (isset($_POST["fullname"])) echo htmlspecialchars(stripslashes($_POST["fullname"])); ?>" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>E-mail address</td>
|
|
||||||
<td>
|
|
||||||
<input name="email" size="30" maxlength="255" type="text" value="<?php if (isset($_POST["email"])) echo $_POST["email"]; ?>" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Family</td>
|
|
||||||
<td>
|
|
||||||
<?php
|
|
||||||
$query = "SELECT familyid, familyname FROM {$OPT["table_prefix"]}families ORDER BY familyname";
|
|
||||||
$families = mysql_query($query) or die("Could not query: " . mysql_error());
|
|
||||||
?>
|
|
||||||
<select name="familyid">
|
|
||||||
<?php
|
|
||||||
while ($row = mysql_fetch_array($families,MYSQL_ASSOC)) {
|
|
||||||
?>
|
|
||||||
<option value="<?php echo $row["familyid"]; ?>"><?php echo $row["familyname"]; ?></option>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
mysql_free_result($families);
|
|
||||||
?>
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" align="center">
|
|
||||||
<input type="submit" value="Submit" onClick="return validateSignup();" />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
|
$smarty->assign('isadmin', $_SESSION['admin']);
|
||||||
|
$smarty->assign('opt', $OPT);
|
||||||
|
$smarty->display('signup.tpl');
|
||||||
?>
|
?>
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
135
src/templates/signup.tpl
Normal file
135
src/templates/signup.tpl
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
{*
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*}
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<title>Gift Registry - Sign Up</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
|
||||||
|
<script language="JavaScript" type="text/javascript">
|
||||||
|
function validateSignup() {
|
||||||
|
field = document.signup.username;
|
||||||
|
if (field == null || field == undefined || !field.value.match("\\S")) {
|
||||||
|
alert("You must supply a username.");
|
||||||
|
field.focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
field = document.signup.fullname;
|
||||||
|
if (field == null || field == undefined || !field.value.match("\\S")) {
|
||||||
|
alert("You must supply your full name.");
|
||||||
|
field.focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
field = document.signup.email;
|
||||||
|
if (!field.value.match("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")) {
|
||||||
|
alert("The e-mail address '" + field.value + "' is not a valid address.");
|
||||||
|
field.focus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
{if isset($error)}
|
||||||
|
<div class="row">
|
||||||
|
<div class="span8 offset2">
|
||||||
|
<div class="alert alert-block">{$error|escape:'htmlall'}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{if isset($action) && $action == "signup" && !isset($error)}
|
||||||
|
<div class="row">
|
||||||
|
<div class="span8 offset2">
|
||||||
|
<div class="well">
|
||||||
|
<p>Thank you for signing up.</p>
|
||||||
|
{if $opt.newuser_requires_approval}
|
||||||
|
<p>The administrators have been informed of your request and you will receive an e-mail once they've made a decision.</p>
|
||||||
|
{else}
|
||||||
|
<p>Shortly, you will receive an e-mail with your initial password.</p>
|
||||||
|
{/if}
|
||||||
|
<p>Once you've received your password, click <a href="login.php">here</a> to login.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{else}
|
||||||
|
<div class="row">
|
||||||
|
<div class="span8 offset2">
|
||||||
|
<div class="well">
|
||||||
|
<p>Complete the form below and click Submit.</p>
|
||||||
|
{if $opt.newuser_requires_approval}
|
||||||
|
<p>The list administrators will be notified of your request by e-mail and will approve or decline your request.
|
||||||
|
</p>
|
||||||
|
<p>If the e-mail address you supply is valid, you will be notified once a decision is made.</p>
|
||||||
|
{else}
|
||||||
|
<p>If the e-mail address you supply is valid, you will shortly receive an e-mail with your initial password.</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="span8 offset2">
|
||||||
|
<form name="signup" method="post" action="signup.php" class="well form-horizontal">
|
||||||
|
<input type="hidden" name="action" value="signup">
|
||||||
|
<fieldset>
|
||||||
|
<legend>Sign Up for the Gift Registry</legend>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="username">Username</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input id="username" name="username" type="text" class="input-xlarge" value="{$username|escape:'htmlall'}" placeholder="Username">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="fullname">Full name</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input id="fullname" name="fullname" type="text" class="input-xlarge" value="{$fullname|escape:'htmlall'}" placeholder="Full name">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="email">E-mail address</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input id="email" name="email" type="text" class="input-xlarge" value="{$email|escape:'htmlall'}" placeholder="you@somewhere.com">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="familyid">Family</label>
|
||||||
|
<div class="controls">
|
||||||
|
<select name="familyid">
|
||||||
|
{foreach from=$families item=row}
|
||||||
|
<option value="{$row.familyid}">{$row.familyname|escape:'htmlall'}</option>
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-actions">
|
||||||
|
<button type="submit" class="btn btn-primary" onClick="return validateSignup();">Submit</button>
|
||||||
|
<button type="button" class="btn" onClick="document.location.href='login.php';">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue