When you first register you will be presented with this form to submit your display. It will be secured by sessions once I am finished with it. As of now it is not so it can be viewed for example purposes.
http://mesquitechristmas.com/local/submit.php
Then in the User CP for registered users which is secured now you have an option to update this information if you need to. So once you click on Edit Display it will show you a form like the one in the link above but it will be filled in with your current information that you entered previsouly from the form in that link. I am able to show that information on the form once you bring it up to edit it. But it doesn't allow you to update it the information and then it is redirected to the user.php which is the main page because this edit page is on using a switch. Now If I can get it to update the information if you chose to change any of it that would be great. So here is the current code. I have been going over it for days and I can not find anything wrong. I am not sure if it is because where the form is calling or what.
The actually form is called at
user.php?action=edit&id=X
Where X is the display id for that logged in user.
The form calls <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Then when you hit submit it takes you back to user.php and doesn't stay on that form page. So I don't know if that is the problem or not.
Anyways here is the code for the entire file.
<?php
require ('session.php');
include ('db_connect.php');
$email = $_SESSION['email'];
if(isset($_POST['submit'])) {
$displayname = $_POST['displayname'];
$displaytype = $_POST['displaytype'];
$description = $_POST['description'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$postal = $_POST['postal'];
$country = $_POST['country'];
$website = $_POST['website'];
mysql_query("UPDATE users SET displayname = '$displayname', displaytype = '$displaytype', description = '$description', address = '$address', address2 = '$address2', city = '$city', state = '$state', postal = '$postal', country = '$country', website = '$website' WHERE email='$email'");
header("location: user.php?action=edit&id=$id");
}
$sql = "SELECT * FROM users WHERE email='$email'";
if ($result = mysql_query($sql)) {
if (mysql_num_rows($result)) {
$row = mysql_fetch_array($result);
$id = $row["id"];
$displayname = $row['displayname'];
$displaytype = $row['displaytype'];
$description = $row['description'];
$address = $row['address'];
$address2 = $row['address2'];
$city = $row['city'];
$state = $row['state'];
$postal = $row['postal'];
$country = $row['country'];
$website = $row['website'];
} else {
die("No user found");
}
} else {
die(mysql_error());
}
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="100%" border="0" align="left" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<td><a href="user.php?action=editprofile">Edit Profile</a> | <a href="submit.php">Add Entry</a> | <a href="user.php?action=edit">Edit Display</a> | <a href="user.php?action=images">Edit Images</a> | <a href="logout.php">Log Out</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td> </td>
<tr>
<td>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table>
<tr>
<td>Display Name*</td><td><input name="displayname" value="<?php echo $displayname; ?>" size="40" type="text"></td></tr>
<tr>
<td>Display Type*</td><td><select name="displaytype"><option value="<?php echo $displaytype; ?>"><?php echo $displaytype; ?></option><option value="Residential">Residential</option><option value="Neighborhood">Neighborhood</option><option value="Commercial">Commercial</option><option value="City/Government">City/Government</option><option value="Sponsored">Sponsored</option></select></td></tr>
<tr><td>Description*</td><td><textarea name="description" cols="30" rows="5"><?php echo $description; ?></textarea></td></tr>
<tr><td>Address*</td><td><input name="address" value="<?php echo $address; ?>" size="40" type="text"></td></tr>
<tr><td>Address 2</td><td><input name="address2" value="<?php echo $address2; ?>" size="40" type="text"></td></tr>
<tr><td>City*</td><td><input name="city" size="30" type="text" value="Mesquite"></td></tr>
<tr><td>State/Province*</td><td><input name="state" size="30" type="text" value="Texas"></td></tr>
<tr><td>Postal Code*</td><td><select name="postal"><option value="<?php echo $postal; ?>"><?php echo $postal; ?></option><option value="75149">75149</option><option value="75150">75150</option><option value="75180">75180</option><option value="75181">75181</option><option value="75185">75185</option><option value="75187">75187</option></select></td></tr>
<tr><td>Country*</td><td><input name="country" size="30" type="text" value="United States"></td></tr>
<tr><td>Website</td><td><input name="website" size="50" value="<?php echo $website; ?>" type="text"></td></tr>
<tr><td> </td></tr>
<tr>
<td colspan="2" style="border-top: 1px solid black;" align="left">
<br />
* Fields are required.</td>
<td colspan="2" style="border-top: 1px solid black;" align="right">
<br />
<input type='submit' name='submit' value='Update'></td></tr>
</tbody>
</table></form>
</td>
</tr>
</table>
Any help would be great
-Thanks