how to save a variable with get_option/update_option inside function post submit
Question
I try to make inside theme custom admin panel a switch select option. but i cannot get the value of switch case. I think i did totally wrong.
<?php if(isset($_POST['wphw_submit'])){
wphw_opt();
}
function wphw_opt(){
$bannerchange = $_POST['bannerchange'];
global $chk;
if( get_option('bannerchange') != get_option($bannerchange)) {
$chk = update_option( 'bannerchange', get_option($bannerchange));
}
}
if(isset($_POST['wphw_submit']) && $chk): endif;?>
<form method="post" action="">
<select name="wphw_submit" onchange="this.form.submit()">
<option value="page1"<?php if ($bannerchange == "page1") { echo " selected"; } ?>>Custom Departure</option>
<option value="page2"<?php if ($bannerchange == "page2") { echo " selected"; } ?>>Fixed Departure</option>
</select>
<input type="submit" name="wphw_submit" value="Save changes" class="button-primary" /></form>
<?php
switch ($bannerchange) {
case 'page2':
break;
case 'page1':
break; }
$bannerchange get always undefined. I can debug this problem with straight way? any help greatly appreciated.
0
3 months
0 Answers
13 views
0
Leave an answer
You must login or register to add a new answer .