jeaker Posted December 16, 2008 Share Posted December 16, 2008 I have the unwanted task of taking someone else's code and making it actually work. I have been fairly successful so far. However, this particular page has given me a fit. It all looks great to me but will not right anything to the database. Everything on the database side is correct because it functions properly with every other page. If there is any comments or suggestion, I would appreciate them. Thank you in advance. <?php include 'unsecure.php'; checksession(); //echo dumpvars(); // $msg = '<br />'; $query = "SELECT UserID, Email FROM User WHERE Email = '" . $_POST['email'] . "'"; $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $password = md5($_POST['password']); $address = $_POST['address']; $address2 = $_POST['address2']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $billaddress = $_POST['billaddress']; $billaddress2 = $_POST['billaddress2']; $billcity = $_POST['billcity']; $billstate = $_POST['billstate']; $billzip = $_POST['billzip']; $securitycode = md5($email . $zip); $msg .= $query . '<br />'; $result = mysql_query($query); $row = mysql_fetch_array($result); if($row) { header("location:newuser.php?msg=1&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } else if($_POST['password'] == '' || $_POST['email'] == '' || $_POST['fname'] == '') { header("location:newuser.php?msg=2&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } else if($_POST['password'] != $_POST['password2']) { header("location:newuser.php?msg=3&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } else if($_POST['sameaddress'] == 'on') { //Billing address checker activated. if($billaddress != '' || $billaddress2 != '' || $billcity != '' || $billstate != '' || $billzip != '') { // Billing address fields are filled in, it's illegal. if($address != '' || $address2 != '' || $city != '' || $state != '' || $zip != '') { // They also filled in one of the other fields, this is very illegal. header("location:newuser.php?msg=5&fname=$fname&lname=$lname&email=$email&address=$address&address2=$address2&city=$city&state=$state&zip=$zip&billaddress=$billaddress&billaddress2=$billaddress2&billcity=$billcity&billstate=$billstate&billzip=$billzip"); exit(); } } } $msg .= 'Success: contact not found. Proceeding.</br >'; $userquery = "INSERT INTO User (FirstName, LastName, Email, Password, securitycode) VALUES ('$fname', '$lname', '$email', '$password', '$securitycode')"; $msg .= $userquery . '<br />'; if(mysql_query($userquery)) { $userid = mysql_insert_id(); $shipquery = "INSERT INTO Address (userid, address, address2, city, state, zip) VALUES ('$userid', '$address', '$address2', '$city', '$state', '$zip')"; $msg .= $shipquery . '<br />'; if(mysql_query($shipquery)) { $shipid = mysql_insert_id(); $billquery = "INSERT INTO Address (userid, address, address2, city, state, zip) VALUES ('$userid', '$billaddress', '$billaddress2', '$billcity', '$billstate', '$billzip')"; $msg .= $shipquery . '<br />'; if(mysql_query($billquery)) { $billid = mysql_insert_id(); $userquery2 = "UPDATE User SET shipaddress = '$shipid', billaddress = '$billid' WHERE UserID = '$userid'"; $msg .= $userquery2 . '<br />'; if(mysql_query($userquery2)) { $msg .= 'All operations successful! User added.'; } else { $msg .= 'Userquery2 failed.<br />'; } } else { $msg .= 'Billing query failed.<br />'; } } else { $msg .= 'Shipping query failed.<br />'; } } else { $msg .= 'Userquery failed.<br />'; } //$msg .= $userquery; //$query .= $_POST[]; /* */ include 'header.php'; //echo dumpvars(); ?> <style type="text/css"> .heading { color:#0033CC; font-family: "Comic Sans MS", sans-serif; font-size:18px; font-weight:bold; text-align:center; } .bluetext { color:#0033CC; font-family: "Comic Sans MS", "Arial", sans-serif; font-size:smaller; font-weight:bold; text-align:left; } </style> <tr> <td height="100%" rowspan="2" valign="top"> <table border="0" cellpadding="0" cellspacing="0" style="background-color: 0033CC" height="100%" align="center"> <tr> <td width="14"><img src="images/tl_blu.gif" width="14" height="14" border="0"></td> <td width="642" colspan="3"></td> <td width="14"><img src="images/tr_blu.gif" width="14" height="14" border="0"></td> </tr> <tr> <td height="100%"></td> <td height="100%" colspan="3" align="right" valign="top"> <table border="0" cellpadding="0" cellspacing="0" style="background-color: FF9900" height="100%"> <tr> <td width="14"><img src="images/tl_blkblu.gif" width="14" height="14" border="0"></td> <td style="background-color: 000000" width="627"></td> <td width="14"><img src="images/tr_blkblu.gif" width="14" height="14" border="0"></td> </tr> <tr valign="top" height="100%"> <td style="background-color: 000000"></td> <td height="100%" style="background-color: 000000" align="center" valign="top"> <table border="0" bgcolor="white" cellspacing="0" height="100%" width="100%"> <tr valign="top"> <td bgcolor="black" valign="top"> <table width="100%" cellpadding="5" cellspacing="5" height="100%"> <tr valign="top"> <td width="100%" class="bluetext" height="100%" valign="top"> <p class="heading">MY SHOPPING BAG </p> Items currently in your shopping bag: <?php echo $msg; ?></td> </tr> </table> </td> </tr> </table> </td> <td style="background-color: 000000"></td> </tr> <tr> <td width="14"><img src="images/bl_blkblu.gif" width="14" height="14" border="0"></td> <td style="background-color: 000000" width="627"></td> <td width="14"><img src="images/br_blkblu.gif" width="14" height="14" border="0"></td> </tr> </table> </td> <td height="100%"></td> </tr> <tr> <td width="14"><img src="images/bl_blu.gif" width="14" height="14" border="0"></td> <td width="642" colspan="3"></td> <td width="14"><img src="images/br_blu.gif" width="14" height="14" border="0"></td> </tr> </table> </td> <td valign="top" width="218"> <?php include 'sidebar.php'; ?> </td> </tr> <?php include 'footer.php'; include 'admin/dbdis.php'; ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted December 16, 2008 Share Posted December 16, 2008 echo each query to view what is actually being sent use mysql_error() after each query to check for errors Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.