Can you give me a hand once again?

Agenator

Member
Messages
341
Reaction score
0
Points
16
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:
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';


?>
So how would I get this to work?
thanks you guys soo much for putting up with my php noobieness :p
 
Last edited:

VPmase

New Member
Messages
914
Reaction score
0
Points
0
I would debug that code if I were you. Use this code to see the values of the $old var:
PHP:
print_r($old);
 

Agenator

Member
Messages
341
Reaction score
0
Points
16
here is what it returned:
PHP:
 [0] => 0 [Admin] => 0 [1] => Josez [FirstName] => Josez [2] => Martinson [LastName] => Martinson [3] => email@yahoo.com [Email] => deadlysnyper@gmail.com [4] => pa22wrd [Password] => pa22wrd [5] => 657 Chapn RD [Address] => 657 Chapn  RD [6] => NA [State] => NA [7] => Pasadena [City] => Pasadena [8] => 91107 [Zip] => 95507 [9] => United States [Country] => United States
(I changed information for privacy but in short, it seems to be outputting what it should, the databases old information) so what now?
 
Last edited:
Top