Sindbad~EG File Manager
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Your Personal Information</title>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<body BGCOLOR="#ffffcc">
<h1 align="center"><strong>
Your Personal Information
</strong></h1>
<a href="privacy.html">privacy policy</a>
<?php
require_once('normalize.php');
require_once('DB.php');
require_once('query.php');
function writeRed($errmsg)
{ echo "<P> <em><font color=\"#FF0000\">";
echo $errmsg;
echo "</font></em></P>";
}
$Username = $_GET['Username'];
$OldUsername = $Username;
$Tried = ! is_null($_POST['Password']);
if((empty($Username) || $Username == "") && (empty($_GET['Firstname']) || trim($_GET['Firstname']) == ""))
$PageState = 'Enter';
else if(!$Tried)
$PageState = 'Edit';
else if($Tried && $PageState != 'Success')
$PageState = 'Submitted';
if($PageState == 'Edit')
{ // fetch data from database
$sql = "SELECT * FROM People WHERE Username='$Username'";
$q = Query($sql);
if($q->numRows() == 0)
print("Oops, can't find data for user $Name. This can't happen.");
$q->fetchInto($row);
$FirstName = $row[2];
$LastName = $row[1];
$Username = $row[5];
$Password = $row[6];
$Password2 = $row[6];
$Email = $row[15];
$Email2 = $row[15];
$InitCity = $row[20];
}
else
{ // used posted data from form (this is actually not necessary, PHP fills these in automatically).
// or not? Apparently not on PacWeb.
$FirstName = trim($_POST['FirstName']);
$LastName = trim($_POST['LastName']);
$Email = trim($_POST['Email']);
$Email2 = trim($_POST['Email2']);
$Username = trim($_POST['Username']);
$Password = trim($_POST['Password']);
$Password2 = trim($_POST['Password2']);
$InitCity = trim($_POST['InitCity']);
}
$Tried = ! is_null($_POST['Password']);
if($Tried)
{ $ValidName = (!empty($FirstName) && !empty($LastName));
$ValidInitCity = !empty($InitCity);
$ValidPassword =
!empty($Password) &&
!empty($Password2) &&
$Password == $Password2;
$ValidEmail = !empty($Email) && !empty($Email2) && $Email== $Email2;
$ValidContact = !empty($Email) ;
$ValidUsername = !empty($Username);
if(!$ValidName || !$ValidContact || !$ValidPassword || !$ValidUsername)
writeRed("Please try again.");
if(!empty($Email) && $Email2 != $Email)
writeRed("You must type your email address twice, and they must match exactly.");
else if(!empty($Email) && !empty($Email2) && $Email != $Email2)
writeRed("You entered your email address twice as required, but the two entries did not agree.");
if(!$ValidName)
writeRed("You must enter both your first and last names.");
if(!$ValidContact)
writeRed("You must enter an email address.");
if(!$ValidUsername)
writeRed("You must give yourself a user name to use when logging on in the future.");
if(!$ValidPassword)
writeRed("You must enter a password, and type it again exactly the same. Either you didn't enter it twice, or you made a typing mistake.");
if(!$ValidInitCity)
writeRed("You must enter a city name; in case you forget your password we will need this to identify you.");
if(trim($Country) != "")
$Country = normalizeCountry($Country);
} // closes if(Tried)
if ($Tried && $ValidPassword && $ValidContact && $ValidName && $PageState == 'Enter' && $ValidInitCity && $ValidEmail)
{ // check if they are trying to duplicate an existing entry
$sql = "SELECT * FROM People WHERE LastName = '$LastName' AND FirstName = '$FirstName';";
$q = Query($sql);
if($q->numRows() > 0 && $PageState == 'Edit')
writeRed("There is already an entry with the same first and last name. Probably you already uploaded your contact information. Start again, log in, and choose to edit your contact information instead of choosing to enter new information. If you really do have the same first and last names as somebody else then alter your first name, for example by including a middle initial.");
else
{ $sql = "SELECT * FROM People WHERE Username = '$Username'";
$q = Query($sql);
if($q->numRows() > 0 && $PageState == 'Enter')
{ writeRed("That user name is already taken. Please choose a different user name; you could try adding some letters or numbers at the end.");
}
else
{ $sql = "INSERT INTO People (
LastName, FirstName, SanskritName, AlsoKnownAs, Username, Password, City, State, Country, PostCode,
StreetAddress, StreetAddress2, HomePhone, CellPhone, Email,URL,InitCity)
VALUES( '$LastName',
'$FirstName',
'$SanskritName',
'$AlsoKnownAs',
'$Username',
'$Password',
'$City',
'$State',
'$Country',
'$PostCode',
'$StreetAddress',
'$StreetAddress2',
'$HomePhone',
'$CellPhone',
'$Email',
'$URL',
'$InitCity');";
$q = Query($sql);
$PageState = 'Success';
print("Your contact information has been successfully stored.");
mail($Email,'MichaelBeeson.com recipes',"You successfully entered your personal data at Michael Beeson\'s recipe website. This email contains the username and password you chose for yourself. You will need this information if you want to change your information, or if you want to post photos and recipes. So save this message, either in your computer or on paper, so that you can recover this information when you need it. Your username is $Username and your password is $Password. This message was automatically generated--do not reply to it.");
?>
<?php
}} // two else's
} // if
if ($Tried && $ValidPassword && $ValidContact && $ValidName && ($PageState == 'Edit' || $PageState == 'Submitted') && $ValidInitCity && $ValidEmail)
{ $sql = "UPDATE People
set LastName = '$LastName',
FirstName = '$FirstName',
Username = '$Username',
Password = '$Password',
Email = '$Email',
InitCity = '$InitCity'
WHERE Username = '$OldUsername';";
$q = Query($sql);
$PageState = 'Success';
$sql = "SELECT PersonID FROM People WHERE Username='$Username';"; // get the UserID for display link
$q = Query($sql);
$q->fetchInto($row);
$UserID = $row[0];
print("Your edited contact information has been successfully stored. Now you could: ");
?>
<?php
} // if
if($PageState != 'Success'){
?>
<P><EM><span class="style1"> </span></EM></P>
<P>
<FORM action= "<?php if($PageState == 'Enter')
echo $_SERVER['PHP_SELF'];
else
echo $_SERVER['PHP_SELF'] . "?Username=$Username";
?>" method="POST">
<TABLE WIDTH="544" BORDER="0" CELLSPACING="1" CELLPADDING="1" id="TABLE2" height="319">
<TR>
<TD width="349">First Name <span class="style1">*</span></TD>
<TD width="182">
<INPUT id="FirstName" type="text" size="30" name="FirstName" value = "<?php echo $FirstName ?>"></TD>
</TR>
<TR>
<TD width="349">Last Name <span class="style1">*</span></TD>
<TD>
<INPUT id="LastName" type="text" size="30" name="LastName" value = "<?php echo $LastName ?>"></TD>
</TR>
<TR>
<TD width="349">City (we will use this to identify you if you forget your password) <span class="style1">*</span></TD>
<TD>
<INPUT id="City" type="text" size="30" name="InitCity" value = "<?php echo $City ?>"></TD>
</TR>
<TR>
<TD width="349">Email address (so we can email your password to you if you forget it) <span class="style1">*</span></TD>
<TD>
<INPUT id="Email" type="text" size="30" name="Email" value = "<?php echo $Email ?>"></TD>
</TR>
<TR>
<TD width="349">Email address (type it a second time to catch errors) <span class="style1">*</span></TD>
<TD>
<INPUT id="Email2" type="text" size="30" name="Email2" value = "<?php echo $Email2 ?>"></TD>
</TR>
<TR>
<TD width="349">User name (make one up, you'll need it to edit or delete your recipes in the future) <span class="style1">*</span></TD>
<TD>
<INPUT id="Username" type="text" size="10" name="Username" value = "<?php echo $Username ?>"></TD>
</TR>
<TR>
<TD width="349">Give yourself a password (to use when logging in) <span class="style1">*</span></TD>
<TD>
<INPUT id="Password" type="password" size="10" name="Password" value = "<?php echo $Password ?>"></TD>
</TR>
<TR>
<TD width="349">Retype your password (to avoid a spelling error)
<span class="style1">*</span> </TD>
<TD>
<INPUT id="Password2" type="password" size="10" name="Password2"
value = "<?php echo $PageState == 'Edit' ? $Password : $Password2 ?>"></TD>
</TR>
</TABLE>
<P align="center">
<INPUT id="SubmitPersonalInfo" type="submit" value="Submit" name="SubmitPersonalInfo"></P>
</FORM>
</P>
<?php
} ?>
</body>
</html>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists