Hello,
I have learned a lot in the past 3 days. lol I have my forms almost completely worked out now.
I am trying to get this to display the inserted content but also change it if it is changed. This is what I have in my file, but i am missing something or wrote something wrong. It doesn't update the info and I don't know why.
PHP Code:
<?php
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
@set_time_limit(0);
// #################### START PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('');
$specialtemplates = array('');
// #################### END PRE-CACHE TEMPLATES AND DATA ######################
// ########################## START BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/adminfunctions_template.php');
// ########################## END BACK-END ############################
print_cp_header($vbphrase['a_settings_manager']);
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'manage';
}
// ########################## FORM ############################
{
$query_settings = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "this_data");
}
if ($_REQUEST['do'] == 'manage')
{
print_form_header('testform', 'update');
print_table_header('Settings Configuration');
print_input_row($vbphrase['site_name'], 'sitename', $query_settings['site_name']);
print_input_row($vbphrase['site_url'], 'siteurl', $query_settings['site_url']);
print_input_row($vbphrase['admin_email'], 'adminemail', $query_settings['admin_email']);
print_submit_row("Save Settings");
}
// ########################## END FORM ############################
// ########################## FORM UPDATE ############################
if ($_POST['do'] == 'update')
{
$vbulletin->input->clean_array_gpc('p', array(
'site_name' => TYPE_STR,
'site_url' => TYPE_STR,
'admin_email' => TYPE_STR
));
if (empty($vbulletin->GPC['site_name']) or empty($vbulletin->GPC['site_url']) or empty($vbulletin->GPC['admin_email']))
{
print_stop_message('invalid_settings_specified');
}
$db->query_write("
UPDATE " . TABLE_PREFIX . "this_data
SET sitename = '" . $db->escape_string($vbulletin->GPC['site_name']) . "',
siteurl = '" . $db->escape_string($vbulletin->GPC['site_url']) . "',
adminemail = '" . $db->escape_string($vbulletin->GPC['admin_email']) . "'
");
define('CP_REDIRECT', 'testform.php?do=manage');
print_stop_message('saved_settings_successfully');
}
// ########################## END FORM UPDATE ############################
// ########################## FORM INSERT ############################
print_cp_footer();
?>
I want it to allow you to enter the data, it will be saved and then display that data entered after it is initially submitted. If you change any of the values, and hit save at the bottom, I want it to update the info to the new info.
I thought that what I have written would work, but it doesn't. What did I miss or do incorrectly?