Hi guys,
i've been blocked by a form problem for the past 2hours.
So in Page.php i have
public function updateModerated() {
//Getting URI and diving it
$URI = explode("/", trim($_SERVER['REQUEST_URI'], "/ ")) ;
//Get the URLsegment 4 on local, 3 online
$URL = $URI[4] ;
$query = new SQLQuery();
$query->select("ID, isModerated, URLSegment");
$query->from("communitymember");
$query->where("URLSegment = '".$URL."'");
$query->orderby("ID ASC") ;
$query->limit(1) ;
if($result = $query->execute()){
$record = $result->current() ;
if($record['isModerated'] == 1){
$fields = new FieldSet(
new CheckboxField("isModerated", "Moderated Profile. Uncheck this after you have reviewed the profile and consider it suitable.", 1)
);
}
else{
$fields = new FieldSet(
new CheckboxField("isModerated", "Moderated Profile. Uncheck this after you have reviewed the profile and consider it suitable.")
);
}
}
else{
$fields = new FieldSet(
new CheckboxField("isModerated", "Moderated Profile. Uncheck this after you have reviewed the profile and consider it suitable.")
);
}
$actions = new FieldSet(new FormAction("updateModeratedDB", "Save"));
return new Form($this, "updateModerated", $fields, $actions);
}
public function updateModeratedDB(){
//Getting URI and diving it
$URI = explode("/", trim($_SERVER['REQUEST_URI'], "/ ")) ;
//Get the URLsegment 4 on local, 3 online
$URL = $URI[4] ;
$query = new SQLQuery();
$query->sql = ("UPDATE communitymember SET isModerated = ".$_POST['isModerated']." WHERE URLSegment = ".$URL);
$query->execute() ;
Director::RedirectBack();
}
and in my Sidebar.ss i have $updateModerated.
The page displays the form ok. now when I click Save, nothing happens and I'm being redirected to the homepage.
Any ideas?
Thanks
K.