I integrated phpbb into my website and I need to change something. I'm trying to UPDATE an entry to my database from another database through a "submit" button. In my databse I have 2 tables. First table called "users"
id name server
1 Alexander 2
2 Robert 1
3 Jack 3
Second one called "server" where I have these:
id name
1 USA
2 EUROPE
3 GLOBAL
Now because I changed to phpbb ( I used to have a normal php system login ), I have to change this:
if (isset($_POST['joinglobal'])) {
/*
* -------------------------------------------------------------------------------
* Securing against Header Injection
* -------------------------------------------------------------------------------
*/
foreach($_POST as $key => $value){
$_POST[$key] = _cleaninjections(trim($value));
}
require '../../assets/setup/db.inc.php';
/*
* -------------------------------------------------------------------------------
* User Joins
* -------------------------------------------------------------------------------
*/
$sql = "UPDATE phpbb5u_users AS u CROSS JOIN server AS s SET u.server = s.id WHERE u.user_id = ? AND s.name = 'GLOBAL'";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
$_SESSION['ERRORS']['scripterror'] = 'SQL ERROR';
header("Location: ../");
exit();
}
else {
mysqli_stmt_bind_param($stmt, "i", $_SESSION['user_id']); }
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$_SESSION['STATUS']['joinstatus'] = 'Joined to GLOBAL';
header("Location: ../");
exit();
mysqli_stmt_close($stmt);
mysqli_close($conn);
}
else {
header("Location: ../");
exit();
}
Already have this in my header:
<?php
define('IN_PHPBB', true);
$phpbb_root_path = 'forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
?>
but how I update the database using submit button from this page:
<button class="btn btn-primary btn-lg" type="submit" value="joineurope" name='joineurope'>Join NOW!</button>
already have the form with action="europe.inc.php" and method="post".
EDIT:
$submit = request_var('submit', '');
if($submit)
{
$serverid = $user->data['server'];
$sql_ary = array (
"server" => 3 );
$sql = 'UPDATE ' . phpbb5u_users . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . (int) $user_id;
$db->sql_query($sql);
}