So Im developing Content Management System for my website! (Very Basic and I know some of these codes are going to be bad).
So Im using PDO and when I run this code.
public static function checkMain()
{
global $dbh;
if (isset($_POST['checkMain']))
{
$checkMain = $dbh->prepare("UPDATE `cms_system` SET `site_closed` = :site_closed LIMIT 1");
$checkMain->bindParam(':site_closed', $_POST['site_closed']);
if (!$checkMain->execute())
{
{
admin::succeed("no error");
return true;
}
admin::error("Uh Oh something is wrong" . $checkMain->errorInfo()[2]);
return;
}
}
}
Nothing happens I get no result nor does anything get updated in the database.
Here is my form tags
<form action="" method='POST' name='theAdminForm' id='theAdminForm'>
<div class='tableborder'>
<div class='tableheaderalt'>Turn your site on/off</div>
<?php admin::checkMain(); ?>
<table width='100%' cellspacing='0' cellpadding='5' align='center' border='0'>
<tr>
<td class='tablerow1' width='40%' valign='middle'><b>Close Site</b><div class='graytext'>If enabled, your site will be closed and show a maintenance page to regular users. Administrators can still login through Housekeeping.</div></td>
<td class='tablerow2' width='60%' valign='middle'><select name='checkMain' class='dropdown'>
<option value='0'>Site Open</option>
<option value='1'>Site Closed</option>
</select>
</td>
</tr>
<tr>
<tr><td align='center' class='tablesubheader' colspan='2' ><input type='submit' value='Apply' class='realbutton' accesskey='s'></td></tr>
</form>
Pretty much in a nutshell Im converting this really old Query
if(isset($_POST['site_closed'])){
$site_closed = addslashes($_POST['site_closed']);
mysql_query("UPDATE cms_system SET site_closed = '".$site_closed."' LIMIT 1") or die(mysql_error());
$msg = "Settings saved successfully.";
The Old Forum Tags.
<form action='index.php?p=maintenance&do=save' method='post' name='theAdminForm' id='theAdminForm'>
<div class='tableborder'>
<div class='tableheaderalt'>Turn your site on/off</div>
<table width='100%' cellspacing='0' cellpadding='5' align='center' border='0'>
<tr>
<td class='tablerow1' width='40%' valign='middle'><b>Close Site</b><div class='graytext'>If enabled, your site will be closed and show a maintenance page to regular users. Administrators can still login through Housekeeping.</div></td>
<td class='tablerow2' width='60%' valign='middle'><select name='site_closed' class='dropdown'>
<option value='1'>Site Closed</option>
<option value='0' <?php if(FetchCMSSetting('site_closed') == "0"){ echo "selected='selected'"; } ?>>Site Open</option>
</select>
</td>
</tr>
<tr>
<tr><td align='center' class='tablesubheader' colspan='2' ><input type='submit' value='Apply' class='realbutton' accesskey='s'></td></tr>
</form>
Into little but more updated version using PDO.