HAving hard time with php(MySQL) and htmt _POST function
Posted: Thu Jan 15, 2009 9:04 pm
Hi y'all. I know I am new to the forums.. I would really appreciate some help. I am not real strong in php... yet. But learning.
I have some stuff that I am trying to get to work, and I know my code is so close, but seems to be missing something. What I am doing is storing a module admin configuration into a MySQL database. The html form when loaded pulls the variables out of the Table and puts them into the Form fields, so you can change what you want and click submit and it will update that table with the new fields. My only problem and all of it works except the check box. It is supposed to store a 1 or 0 based off of the check box. SO my problem.
1. The form will not update the table with the new post variable 1 or 0.
2. The form will not load the existing variable and make the check box checked or uncheck depending on if the table already has a 1 or 0.
I hope that was clear enough. Here is the code.
This is the post form
and the php function to load and post variables
Thanks for your help
I have some stuff that I am trying to get to work, and I know my code is so close, but seems to be missing something. What I am doing is storing a module admin configuration into a MySQL database. The html form when loaded pulls the variables out of the Table and puts them into the Form fields, so you can change what you want and click submit and it will update that table with the new fields. My only problem and all of it works except the check box. It is supposed to store a 1 or 0 based off of the check box. SO my problem.
1. The form will not update the table with the new post variable 1 or 0.
2. The form will not load the existing variable and make the check box checked or uncheck depending on if the table already has a 1 or 0.
I hope that was clear enough. Here is the code.
This is the post form
Code: Select all
echo "<h3>Settings</h3>";
echo $message != "" ? "<p><b>$message</b></p>" : "" ;
echo "<form action='$modulelink' method='post'>";
echo "<table><tr><td>Version: </td><td>".$settings['Version']."</td></tr>";
echo "<tr><td>Enabled:</td><td><input type='checkbox' name='Enabled' value='".($settings['Enabled'] == '1' ? 'CHECKED' : '')."'/></td></tr>";
echo "<tr><td>License Key:</td><td><input size='20' type='text' name='LicenseKey' value='".$settings['LicenseKey']."'/></td></tr>";
echo "<tr><td>System Name:</td><td><input size='20' type='text' name='SystemName' value='".$settings['SystemName']."'/></td></tr>";
echo "<tr><td>Folder Location:</td><td><input type='text' size='5' name='folder' value='".$settings['folder']."'/></td></tr>";
echo "<tr><td> </td><td><input type='submit' name='PostSettings' value='Submit Form'/></td></tr></table>";
echo "</form>";Code: Select all
if(isset($_POST['PostSettings'])){
$settings['Enabled'] = (isset($_POST['Enabled']) && $_POST['Enabled'] == '1') ? 1 : 0;
$settings['SystemName'] = $_POST['SystemName'];
$settings['LicenseKey'] = $_POST['LicenseKey'];
$settings['folder'] = $_POST['folder'];
$message = "Details Saved";
phpBB3SaveSetting($settings);
}