Ok since no one had any thoughts on this, I figured I would make an attempt. With the help of reading a book by Larry Ullman and adapting one of the lesson scripts. I have been able to acomplish what i needed. Here is my script, please be kind to me when you judge it.
```php
/* This is a simple way to change ownership of orders
Uses: move orders placed as guest to their account
user has settup multiply accounts, move orders to one account.
this does not change anything on the order
*/
$page_title = 'Order change owner';
// include ('includes/header.html'); // reminder to self to make thinks pretty later.
// Check if the form has been submitted:
if (isset($_POST['submitted'])) {
require_once ('../mysqli-connect.php'); // Connect to the db.
$errors = array(); // Initialize an error array.
// Check for a Order ID:
if (empty($_POST['order_num'])) {
$errors[] = 'You forgot to enter an order id.';
} else {
$fn = mysqli_real_escape_string($dbc, trim($_POST['order_num']));
}
// Check for a user ID:
if (empty($_POST['user_num'])) {
$errors[] = 'You forgot to enter an user id.';
} else {
$ln = mysqli_real_escape_string($dbc, trim($_POST['user_num']));
}
if (empty($errors)) { // If everything's OK.
// Createe query for the database...
// Make the query:
$q = "UPDATE cscart_orders SET user_id = $ln WHERE order_id = $fn";
$r = @mysqli_query ($dbc, $q); // Run the query.
if ($r) { // If it ran OK.
// Print a message:
echo '
Thank you!
Your change has been registered!
';
} else { // If it did not run OK.
// Public message:
echo '
System Error
You could not be change order due to a system error. We apologize for any inconvenience.
';
// Debugging message:
echo '
' . mysqli_error($dbc) . '
Query: ' . $q . '
';
} // End of if ($r) IF.
mysqli_close($dbc); // Close the database connection.
// Include the footer and quit the script:
// include ('includes/footer.html'); // reminder to self to make thinks pretty later.
exit();
} else { // Report the errors.
echo '
Error!
The following error(s) occurred:
';
foreach ($errors as $msg) { // Print each error.
echo " - $msg
\n";
}
echo '
Please try again.
';
} // End of if (empty($errors)) IF.
mysqli_close($dbc); // Close the database connection.
} // End of the main Submit conditional.
?>
Change Order Owner
Order Number:
New Owner:
// include ('includes/footer.html'); // reminder to self to make thinks pretty later.
?>
```