adding a PHP settings page
Posted: Mon Jan 17, 2011 3:07 pm
I have a php script named settings.php. In the file I have 3 settings that I need to read from a mysql database, and then display the on, off status of each setting. That part I know how to do.
The problem I'm having is getting it to update the database when I change the value from a drop down box and click the submit button.
The idea is too have 3 settings that I can turn on, or off from a mysql database. Below is my code. Can some one Please HELP
I been programing in PHP for a little more then 4 years. I wanted to learn how to use classes and custom options.
PLEASE HELP......
Joe
The problem I'm having is getting it to update the database when I change the value from a drop down box and click the submit button.
The idea is too have 3 settings that I can turn on, or off from a mysql database. Below is my code. Can some one Please HELP
Code: Select all
<link href="mainframe.css" rel="stylesheet" type="text/css">
<?php
require_once '../config.php';
error_reporting(-1);
ini_set("display_errors", -1);
$db = new DbConnector();
$db->DbConnector();
if(isset($_POST['submit'])) {
$temp1 = $_POST['temp1'];
$temp2 = $_POST['temp2'];
$temp3 = $_POST['temp3'];
$db->query("'UPDATE '".SETTINGS_TABLE."' SET option='".$temp1."', option='".$temp2."', option='".$temp3."''");
echo 'Process complete';
}
$result = $db->query('SELECT * FROM '.SETTINGS_TABLE);
echo '<table border="2">';
echo '<tr>';
echo '<form action="settings.php" methed="post">';
$t = 1;
while($row = $db->fetchArray($result))
{
echo '<tr>';
echo '<td>'.$row['setname'].'</td><td><select size="1" name=temp'.$t.'>';
if($row['option'] == 'on') {
echo '<option value="on" selected>on</option>';
} else {
echo '<option value="on">on</option>';
}
if($row['option'] == 'off') {
echo '<option value="off" selected>off</option>';
} else {
echo '<option value="off">off</option>';
}
echo '</select>';
echo '</td>';
echo "</tr>";
$t = $t = 1;
}
echo '<td><input type="submit" value="Submit" name="submit">';
echo '</td>';
echo "</tr>";
echo "</form>";
echo "</table>";
/*
*/
?>
<h2>Settings</h2>
<a href = "admin.php">Admin Panel</a>PLEASE HELP......
Joe