Okay so Ive got this update page and I have a simple problem (It least I hope its simple) If a field is blank, I need the page to reeinsert the old information from the database. Currently if a field is blank it will insert a blank line. Heres my code:
So how would I get this to work?
thanks you guys soo much for putting up with my php noobieness
PHP:
<?php
ob_start();
session_start();
include 'config.php';
include 'opendb.php';
mysql_select_db($dbname) or die(mysql_error());
$currentemail = $_SESSION['currentemail'];
$oldquery = "SELECT * FROM information WHERE email = '$currentemail'";
$old = mysql_fetch_array(mysql_query($oldquery));
$firstname = empty($_POST['firstname']) ? $old['firstname'] : $_POST['firstname'];
$lastname = empty($_POST['lastname']) ? $old['lastname'] : $_POST['lastname'];
$email = empty($_POST['email']) ? $old['email'] : $_POST['email'];
$password = empty($_POST['password']) ? $old['password'] : $_POST['password'];
$address = empty($_POST['address']) ? $old['address'] : $_POST['address'];
$state = empty($_POST['state']) ? $old['state'] : $_POST['state'];
$city = empty($_POST['city']) ? $old['city'] : $_POST['city'];
$zip = empty($_POST['zip']) ? $old['zip'] : $_POST['zip'];
$country = empty($_POST['country']) ? $old['country'] : $_POST['country'];
$edit = empty($_POST['edit']) ? $old['edit'] : $_POST['country'];
$delete = empty($_POST['delete']) ? $old['delete'] : $_POST['delete'];
$query = "UPDATE information SET email = '".$email."', FirstName = '".$firstname."', lastname = '".$lastname."', password = '".$password."', address = '".$address."', city = '".$city."', state = '".$state."', zip = '".$zip."', country = '".$country."'
WHERE email = '".$_SESSION['currentemail']."'";
//$result = mysql_query($query);
echo $old;
mysql_query($query) or die ('not working right now');
include 'closedb.php';
?>
thanks you guys soo much for putting up with my php noobieness
Last edited: