Hey, I’m having a little trouble with getting some stored settings to actually be entered into my database after being posted from a form, and I can’t figure out why. How exactly is this stuff posted and what could interfere with it? I was getting some ‘header already set’ errors before, would this give it problems? Below is some of my code: [php]<?php
if (!defined(‘WEB_ROOT’)) {
exit;
}
$userid = $_SESSION[‘account_user_id’];
// get current configuration
$sql = “SELECT user_id, p_first_name, p_last_name, p_address1, p_address2, p_phone, p_county, p_city, p_post_code, s_first_name, s_last_name, s_address1, s_address2, s_phone, s_county, s_city, s_post_code
FROM table_user_info
WHERE user_id = $userid”;
$result = dbQuery($sql);
// extract the shop config fetched from database
// make sure we query return a row
if (dbNumRows($result) > 0) {
extract(dbFetchAssoc($result));
} else {
// since the query didn’t return any row ( maybe because you don’t run plaincart.sql as is )
// we just set blank values for all variables
$p_first_name = $p_last_name = $p_address1 = $p_address2 = $p_phone = $p_county = $p_city = $p_post_code = $s_first_name = $s_last_name = $s_address1 = $s_address2 = $s_phone = $s_county = $s_city = $s_post_code = ‘’;
}
?>
This will be used to automatically fill in parts of your order information on checkout, any fields left blank will not be included. You will be able to add to or change this information on checkout, however it must be changed here to become permanent.
|
|
Payment Information
|
|
First Name | |
Last Name | |
Address 1 | |
Address 2 | |
Phone Number | |
Province / County | |
City | |
Postal Code |
Shipping Information
|
|
First Name | |
Last Name | |
Address 1 | |
Address 2 | |
Phone Number | |
Province / County | |
City | |
Postal Code |
[/php] [php]<?php $root = realpath($_SERVER["DOCUMENT_ROOT"]); require_once "$root/zippstore/resources/config.php"; require_once "$root/zippstore/useraccount/resources/userfunctions.php"; checkUser();
$action = isset($_GET[‘action’]) ? $_GET[‘action’] : ‘’;
switch ($action) {
case 'update' :
updateAccountInfo();
break;
default :
// if action is not defined or unknown
// move to main page
header('Location: index.php');
}
function updateAccountInfo()
{
$p_first_name = $_POST[‘p_first_name’];
$p_last_name = $_POST[‘p_last_name’];
$p_address1 = $_POST[‘p_address1’];
$p_address2 = $_POST[‘p_address2’];
$p_phone = $_POST[‘p_phone’];
$p_county = $_POST[‘p_county’];
$p_city = $_POST[‘p_city’];
$p_post_code = $_POST[‘p_post_code’];
$s_first_name = $_POST[‘p_first_name’];
$s_last_name = $_POST[‘p_last_name’];
$s_address1 = $_POST[‘p_address1’];
$s_address2 = $_POST[‘p_address2’];
$s_phone = $_POST[‘p_phone’];
$s_county = $_POST[‘p_county’];
$s_city = $_POST[‘p_city’];
$s_post_code = $_POST[‘p_post_code’];
$userid = $_SESSION[‘account_user_id’];
$sql = "UPDATE table_user_info SET
p_first_name = '$p_first_name',
p_last_name = '$p_last_name',
p_address1 = '$p_address1',
p_address2 = '$p_address2',
p_phone = '$p_phone',
p_county = '$p_county',
p_city = '$p_city',
p_post_code = '$p_post_code',
s_first_name = '$s_first_name',
s_last_name = '$s_last_name',
s_address1 = '$s_address1',
s_address2 = '$s_address2',
s_phone = '$s_phone',
s_county = '$s_county',
s_city = '$s_city',
s_post_code = '$s_post_code'
WHERE user_id = '$userid'";
$result = dbQuery($sql);
header("Location: index.php");
}
?>[/php]