Dr.CustUmz
06-07-2020, 05:25 AM
So I am trying to insert data into the DB via the default vB pages. I have created a simple custom page
<?php
error_reporting(E_ALL & ~E_NOTICE);
define('THIS_SCRIPT', 'installs');
define('CSRF_PROTECTION', true);
define('CSRF_SKIP_LIST', '');
$globaltemplates = array(
'installs'
);
require_once('./global.php');
$navbits = array();
$navbits[$parent] = 'Installs Page';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('installs') . '");');
?>
and on this page I am trying to add a If post add to the DB
if (isset($_POST['username'])) {
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "installs (
username,
cookie
) VALUES (" .
$_POST['username'] .", '" .
$_POST['cookie'] . "'
)");
}
although I am having trouble getting that data to insert. I have also created a separate php file which has no issues inserting the data:
if(isset($_POST['username'])){
$conn = mysqli_connect("localhost", "root", "password", "install") or die("Connection Error: " . mysqli_error($conn));
mysqli_query($conn, "INSERT INTO installs (username,cookie) VALUES ('" . $_POST['username']. "', '" . $_POST['cookie']. "')");
}
I just wanted to incorporate this into into the main system so I'm already connected to the database. Is there a way to do this? I have looked at other core files that do this and I thought I had everything I needed to do this, but apparently not.
<?php
error_reporting(E_ALL & ~E_NOTICE);
define('THIS_SCRIPT', 'installs');
define('CSRF_PROTECTION', true);
define('CSRF_SKIP_LIST', '');
$globaltemplates = array(
'installs'
);
require_once('./global.php');
$navbits = array();
$navbits[$parent] = 'Installs Page';
$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('installs') . '");');
?>
and on this page I am trying to add a If post add to the DB
if (isset($_POST['username'])) {
$db->query_write("
INSERT INTO " . TABLE_PREFIX . "installs (
username,
cookie
) VALUES (" .
$_POST['username'] .", '" .
$_POST['cookie'] . "'
)");
}
although I am having trouble getting that data to insert. I have also created a separate php file which has no issues inserting the data:
if(isset($_POST['username'])){
$conn = mysqli_connect("localhost", "root", "password", "install") or die("Connection Error: " . mysqli_error($conn));
mysqli_query($conn, "INSERT INTO installs (username,cookie) VALUES ('" . $_POST['username']. "', '" . $_POST['cookie']. "')");
}
I just wanted to incorporate this into into the main system so I'm already connected to the database. Is there a way to do this? I have looked at other core files that do this and I thought I had everything I needed to do this, but apparently not.