profile page converted

This commit is contained in:
Ryan Walberg 2012-11-11 23:05:22 +00:00
parent 58e899c3da
commit 9d76f9b999
2 changed files with 135 additions and 96 deletions

View file

@ -64,102 +64,22 @@ if (!empty($_POST["action"])) {
exit;
}
}
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Gift Registry - Update Profile</title>
<link href="styles.css" type="text/css" rel="stylesheet" />
<script language="JavaScript" type="text/javascript">
function confirmPassword() {
var theForm = document.forms["changepwd"];
if (theForm.newpwd.value != theForm.confpwd.value) {
alert("Passwords don't match.");
return false;
}
return true;
}
function validateProfile() {
var theForm = document.forms["profile"];
if (!theForm.fullname.value.match("\\S")) {
alert("A full name is required.");
theForm.fullname.focus();
return false;
}
if (!theForm.email.value.match("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")) {
alert("The e-mail address '" + theForm.email.value + "' is not a valid address.");
theForm.email.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<form name="changepwd" action="profile.php" method="POST" onSubmit="return confirmPassword();">
<input type="hidden" name="action" value="changepwd">
<p>
<table class="partbox" cellpadding="3">
<tr class="partboxtitle">
<td colspan="2" align="center">Change Password</td>
</tr>
<tr>
<td>New Password</td>
<td><input type="password" name="newpwd"></td>
</tr>
<tr>
<td>Confirm Password</td>
<td><input type="password" name="confpwd"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Change Password"></td>
</tr>
</table>
</p>
</form>
<?php
$query = "SELECT fullname, email, email_msgs, comment FROM {$OPT["table_prefix"]}users WHERE userid = " . $userid;
$rs = mysql_query($query) or die("You don't exist: " . mysql_error());
$row = mysql_fetch_array($rs,MYSQL_ASSOC);
?>
<form name="profile" action="profile.php" method="POST" onSubmit="return validateProfile();">
<input type="hidden" name="action" value="save">
<p>
<table class="partbox" cellpadding="3">
<tr class="partboxtitle">
<td colspan="2" align="center">Update Profile</td>
</tr>
<tr>
<td>Full Name</td>
<td><input type="text" name="fullname" value="<?php echo htmlspecialchars($row["fullname"]); ?>"></td>
</tr>
<tr>
<td>E-mail Address</td>
<td><input type="text" name="email" value="<?php echo htmlspecialchars($row["email"]); ?>"></td>
</tr>
<tr>
<td colspan="2">
<input type="checkbox" name="email_msgs" <?php if ($row["email_msgs"] == 1) echo "CHECKED"; ?>>E-mail me a copy of every message
</td>
</tr>
<tr>
<td colspan="2">
Comments / shipping address / etc. (optional)<br />
<textarea name="comment" rows="5" cols="40"><?php echo htmlspecialchars($row["comment"]); ?></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Update Profile"></td>
</tr>
</table>
</p>
</form>
<?php
$row = mysql_fetch_array($rs, MYSQL_ASSOC);
$fullname = $row['fullname'];
$email = $row['email'];
$email_msgs = $row['email_msgs'];
$comment = $row['comment'];
mysql_free_result($rs);
?>
<p>
<a href="index.php">Back to main</a>
</p>
</body>
</html>
define('SMARTY_DIR',str_replace("\\","/",getcwd()).'/includes/Smarty-3.1.12/libs/');
require_once(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty();
$smarty->assign('fullname', $fullname);
$smarty->assign('email', $email);
$smarty->assign('email_msgs', $email_msgs);
$smarty->assign('comment', $comment);
$smarty->assign('opt', $OPT);
$smarty->display('profile.tpl');

119
src/templates/profile.tpl Normal file
View file

@ -0,0 +1,119 @@
{*
This program is free software; you can redistribute it and/or modify
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 - Update Profile</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 confirmPassword() {
var theForm = document.forms["changepwd"];
if (theForm.newpwd.value != theForm.confpwd.value) {
alert("Passwords don't match.");
return false;
}
return true;
}
function validateProfile() {
var theForm = document.forms["profile"];
if (!theForm.fullname.value.match("\\S")) {
alert("A full name is required.");
theForm.fullname.focus();
return false;
}
if (!theForm.email.value.match("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*")) {
alert("The e-mail address '" + theForm.email.value + "' is not a valid address.");
theForm.email.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<div class="container">
<div class="row">
<div class="span8 offset2">
<form name="changepwd" action="profile.php" method="POST" onSubmit="return confirmPassword();" class="well form-horizontal">
<input type="hidden" name="action" value="changepwd">
<fieldset>
<legend>Change Password</legend>
<div class="control-group">
<label class="control-label" for="newpwd">New password</label>
<div class="controls">
<input type="password" id="newpwd" name="newpwd" class="input-xlarge">
</div>
</div>
<div class="control-group">
<label class="control-label" for="confpwd">Confirm password</label>
<div class="controls">
<input type="password" id="confpwd" name="confpwd" class="input-xlarge">
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Change Password</button>
<button type="button" class="btn" onclick="document.location.href='index.php';">Cancel</button>
</div>
</fieldset>
</form>
</div>
</div>
<div class="row">
<div class="span8 offset2">
<form name="profile" action="profile.php" method="POST" onSubmit="return validateProfile();" class="well form-horizontal">
<input type="hidden" name="action" value="save">
<fieldset>
<legend>Update Profile</legend>
<div class="control-group">
<label class="control-label" for="fullname">Full name</label>
<div class="controls">
<input type="text" id="fullname" name="fullname" class="input-xlarge" value="{$fullname}">
</div>
</div>
<div class="control-group">
<label class="control-label" for="email">E-mail address</label>
<div class="controls">
<input type="text" id="email" name="email" class="input-xlarge" value="{$email}">
</div>
</div>
<div class="control-group">
<label class="control-label" for="email_msgs">Copy on msg</label>
<div class="controls">
<input type="checkbox" id="email_msgs" name="email_msgs" {if $email_msgs}CHECKED{/if}>
E-mail me a copy of every message
</div>
</div>
<div class="control-group">
<label class="control-label" for="comment">Comments / shipping address / etc. (optional)</label>
<div class="controls">
<textarea id="comment" name="comment" rows="5" cols="40">{$comment}</textarea>
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Update Profile</button>
<button type="button" class="btn" onclick="document.location.href='index.php';">Cancel</button>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</body>
</html>