Okay so I need some help create an update page for a site that I'm working on so that if someone registers they can update their address to recieve a newsletter. I have the form all put together but I'm just having trouble on getting the php code to work properly. Specifically I need help getting the query to update all of the fields into all of their respective tables. How would I go about doing this? Also I dont know how to make sure that they query doesn't update blank boxes, so how can I get the query to skip over these?
Thanks
Heres the code:
(ignore the part where It actually runs the query since this is where I need help anyway)
Thanks
Heres the code:
PHP:
<?php
session_start();
include 'config.php';
include 'opendb.php';
mysql_select_db($dbname) or die(mysql_error());
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$password = $_POST['password'];
$address = $_POST['address'];
$state = $_POST['state'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$country = $_POST['country'];
$currentemail = $_SESSION['currentemail'];
$edit = $_POST['edit'];
$delete = $_POST['delete'];
$value = arry("email", "firstname", "lastname", "email", "password", "address", "state", "city", "zip", "country");
$arr = arry("$email", "$firstname", "$lastname", "$email", "$password", "$address", "$state", "$city", "$zip", "$country");
$query = "UPDATE information SET (FirstName, LastName, Email, Password, Address, State, City, Zip, Country)
Values
('$firstname', '$lastname', '$email', '$password', '$address', '$state', '$city', '$zip', '$country') WHERE email = '$currentemail'";
$query4 = "UPDATE information SET admin = '$edit' WHERE email = '$currentemail'";
$deletequery = "DELETE FROM information WHERE email = '$email'";
$result = mysql_query($query);
echo $currentemail;
if ($delete=="1"){
mysql_query($deletequery) or die ('crap');
echo "success";
}
else
mysql_query($query) or die ('crap');
include 'closedb.php';
?>
Last edited: