blank page after editing
Posted: Mon May 07, 2007 7:44 pm
i added some stuff to this php code, and now the page doesnt load. did i put in something extra/need to add something? i added all the stuff about "uID's"
Code: Select all
<?
$username = $_SESSION['username'];
if (isset($_GET["form"]) && $_GET['form'] == "password") {
$e = "none";
$p1 = $_POST['pass1'];
$p2 = $_POST['pass2'];
//validate password
if (!username_field($p1) or $p1 == "") {
$e = "password";
}
//make sure the same
if ($p1 != $p2) {
$e = "match";
}
if ($e == "none") {
$pass = md5($p1);
$query="UPDATE users SET password='$pass' WHERE username='$username'";
mysql_query($query) or die("Could not insert data because ".mysql_error());
echo '<div align=center><font color=red>Password Changed<font></div>';
echo '<meta http-equiv="refresh" content="3;url=main.php">';
}
if (isset($_GET["form"]) && $_GET['form'] == "uid") {
$e = "none";
$uid1 = $_POST['uid1'];
$uid2 = $_POST['uid2'];
//validate uid
if (!username_field($uid) or $uid == "") {
$e = "uid";
}
//make sure the same
if ($uid1 != $uid2) {
$e = "match";
}
if ($e == "none") {
$uid = md5($uid);
$query="UPDATE users SET uid='$uid' WHERE username='$username'";
mysql_query($query) or die("Could not insert data because ".mysql_error());
echo '<div align=center><font color=red>Password Changed<font></div>';
echo '<meta http-equiv="refresh" content="3;url=main.php">';
//validate form
//get vars
if (isset($_GET["form"]) && $_GET['form'] == "submit") {
$Email = $_POST['email'];
$fname = $_POST['fname'];
$address = $_POST['address'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$error = "none";
$pass = md5($password);
//validate
//validate zip
if (!zip_field($zip) or $zip == "") {
$error = "zip";
}
//validate city
if (!other_fields($city) or $city == "") {
$error = "city";
}
//validate address
if (!other_fields($address) or $address == "") {
$error = "address";
}
//valiudate fname
if (!name_fields($fname) or $fname == "") {
$error = "firstname";
}
//validate email
if (!check_email($Email)) {
$error = "Email";
}
//check to see if email is used
$sql = 'SELECT * FROM `users` WHERE `email` = "'.$Email.'"';
$query = mysql_query ($sql);
$data = mysql_query("SELECT * FROM users WHERE username='$username'")
or die(mysql_error());
$info = mysql_fetch_array($data);
$email = $info['email'];
if (mysql_num_rows($query) !=0 && $Email != $email) {
$error = "doubleemail";
}
//if not insert data
if ($error == "none") {
$query="UPDATE users SET fname='$fname', email='$Email', address='$address', city='$city', zip='$zip' WHERE username='$username'";
mysql_query($query) or die("Could not insert data because ".mysql_error());
echo '<div align=center><font color=red>Account Updated<font></div>';
echo '<meta http-equiv="refresh" content="3;url=main.php">';
}
}
?>
<?
$data = mysql_query("SELECT * FROM users WHERE username='$username'")
or die(mysql_error());
$info = mysql_fetch_array($data);
$email = $info['email'];
$name = $info['fname'];
$address = $info['address'];
$city = $info['city'];
$state = $info['state'];
$zip = $info['zip'];
$country = $info['country'];
?>
<form action="editaccount.php?form=submit" method="post" name="edit">
<p> </p>
<table width="300" border="0" align="center" class="table" style="border: 1px dashed red; padding: 4px 4px 4px 4px; ">
<tr>
<td colspan="2"><div align="center"><?
if ($error == "firstname") { echo "<font color=red><center>Your First Name is Incorrect</center></font>"; }
if ($error == "address") { echo "<font color=red><center>Your Address is Incorrect</center></font>"; }
if ($error == "city") { echo "<font color=red><center>Your City is Incorrect</center></font>"; }
if ($error == "state") { echo "<font color=red><center>Your State is Incorrect</center></font>"; }
if ($error == "zip") { echo "<font color=red><center>Your Zip Code is Incorrect</center></font>"; }
if ($error == "Email") { echo "<font color=red><center>Your Email is Incorrect</center></font>"; }
if ($error == "doubleemail") {echo '<center><font color="#ff0000">This Email is already in use. <br>Please Try Again'; }
?></div></td>
</tr>
<tr>
<td colspan="2" style="border-bottom:1px dashed red "><div align="left"><strong>Your Account </strong></div></td>
</tr>
<tr>
<td colspan="2"><div align="center"><strong>Account Information </strong></div></td>
</tr>
<tr>
<td width="141">Username:</td>
<td width="320"><? echo "$username" ?></td>
</tr>
<tr>
<td>Email:</td>
<td><input name="email" type="text" id="email" size="20" value="<? echo "$email"; ?>" /></td>
</tr>
<tr>
<td colspan="2"><div align="center"><strong>Shipping Information </strong></div></td>
</tr>
<tr>
<td height="26">Full Name: </td>
<td><input name="fname" type="text" id="fname" size="20" value="<? echo "$name"; ?>" /></td>
</tr>
<tr>
<td>Address:</td>
<td><input name="address" type="text" id="address" size="20" value="<? echo "$address"; ?>" /></td>
</tr>
<tr>
<td>City:</td>
<td><input name="city" type="text" id="city" size="20" value="<? echo "$city"; ?>" /></td>
</tr>
<tr>
<td>State:</td>
<td><? echo "$state"; ?>
</td>
</tr>
<tr>
<td>Zip:</td>
<td><input name="zip" type="text" id="zip" size="20" value="<? echo "$zip"; ?>" /></td>
</tr>
<tr>
<td>Country:</td>
<td><? echo "$country"; ?></td>
</tr>
<tr>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="Submit" value="Submit" class="button" />
</div></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
</table>
</form>
<form action="editaccount.php?form=password" method="post" name="edit">
<table width="300" border="0" align="center" class="table" style="border: 1px dashed red; padding: 4px 4px 4px 4px; ">
<tr>
<td colspan="2"><div align="center"><?
if ($e == "match") { echo "<font color=red><center>The Passwords Do Not Match</center></font>"; }
if ($e == "password") { echo "<font color=red><center>Your Password is Invalid</center></font>"; }
?></div></td>
</tr>
<tr>
<Td colspan="2" style="border-bottom:1px dashed red "><strong>
Change Password
</strong></Td>
</tr>
<tr>
<td>
Password
</td>
<td>
<input name="pass1" type="password" id="pass1">
</td>
</tr>
<tr>
<td>
Retype Password
</td>
<td>
<input name="pass2" type="password" id="pass2">
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="Submit" value="Change" class="button" />
</div></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
</table>
</form>
</td>
<form action="editaccount.php?form=uid" method="post" name="edit">
<table width="300" border="0" align="center" class="table" style="border: 1px dashed red; padding: 4px 4px 4px 4px; ">
<tr>
<td colspan="2"><div align="center"><?
if ($e == "match") { echo "<font color=red><center>The ID's Do Not Match</center></font>"; }
if ($e == "uid") { echo "<font color=red><center>Your ID is Invalid</center></font>"; }
?></div></td>
</tr>
<tr>
<Td colspan="2" style="border-bottom:1px dashed red "><strong>
Change Referral ID
</strong></Td>
</tr>
<tr>
<td>
Password
</td>
<td>
<input name="uid1" type="password" id="uid1">
</td>
</tr>
<tr>
<td>
Retype Referral ID
</td>
<td>
<input name="uid2" type="uid" id="uid2">
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="Submit" value="Change" class="button" />
</div></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
</table>
</form>
</td>
