Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Action Page in Admin Pack
05-02-2012, 01:55 AM (This post was last modified: 05-02-2012 09:10 PM by thruska.)
Post: #1
Action Page in Admin Pack
This must seem a dumb question, but I need clarification on how exactly one directs the form to submit to itself.
I am using a none-existent name (myself) in lieu of "somepage" in the index.php script. But when clicking the save button after semi-filling out of the form (i.e. submitting an incomplete form), I do not appear to be picking the form up on isset.
here's my code...

PHP Code:
    $menuopts = array(
        
"Just Leasing Content Management System" => array(
            
"Showroom Entry Page" => BB_GetRequestURLBase() . "?action=myself&sec_t=" BB_CreateSecurityToken("myself")
        )
    ); 

After the save button is clicked it jumps to the successfully created message???

PHP Code:
    if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "myself")
    {

        if (isset(
$_REQUEST["rank"]))
        {

            if (
BB_GetPageMessageType() != "error")
            {
echo 
"Form Check";
                if (
check_empty_fields())
                {
// process the form data
                
var_dump ($req_fields);
// [Save data here.]
echo "Save record code!";
                
BB_RedirectPage("success""Successfully saved the data.");
                }
            }
        } 

Upon submission (Save button) the logic jumps straight to the successfully created message and none of the above echo's are displayed???

If you don't squeak, you won't get oiled!Cool
Find all posts by this user
Quote this message in a reply
05-02-2012, 09:13 PM (This post was last modified: 05-02-2012 09:20 PM by thruska.)
Post: #2
RE: Action Page in Admin Pack
Actually, it probably does. PHP buffers the output until it has enough to actually output. The BB_RedirectPage() outputs a "Location" header if nothing has been output yet.

Put an 'exit()' call after your 'echo' statements but before the BB_RedirectPage() call.

Also, not a dumb question. Admin Pack is one of those tools that takes time to get used to.

I see a potential problem with the order of operations.

PHP Code:
if (isset($_REQUEST["rank"]))
        {
            if (
$_REQUEST["rank"] == "")  BB_SetPageMessage("error""Please select a rank.");
            else if (...) ...
            
// Do other checks.

            
if (BB_GetPageMessageType() != "error")
            {
                
// Save data here.
echo "Save record here.";
exit();

                
BB_RedirectPage("success""Successfully saved the data.");
            }
        } 

Basically, this allows you to check each field and set the error message if a test doesn't pass. Then the BB_GetPageMessageType() call checks to see if there is an error message that needs to be displayed. If so, it just falls through to the form. If not, it goes to save the data.

Author of Barebones CMS

If you found my reply to be helpful, be sure to donate!
All funding goes toward future product development.
Find all posts by this user
Quote this message in a reply
05-02-2012, 11:37 PM
Post: #3
RE: Action Page in Admin Pack
Thank you Thruska! Now I'm on-track!

If you don't squeak, you won't get oiled!Cool
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

© CubicleSoft