Problem with error handling and conditionals

0 Jeremy Benson · November 13, 2014
Hey,

I have this page set up with two forms. The forms are stored in a different folder and included via include(). They each have a conditional set up above the submit button for message display. I use $_GET variables to decide which form shows a message if there's one to be shown. The problem is it's not working properly.

One form is for skinning user's channel the other form is for submitting a video.

I echo out the three main variable I'm using at the top of the page so I know when I press the submit button on either form their getting the right values when I'm directed back with the query string.

Here's the values from echo when submitting the skinning form...

From: basicinfo
option: channel
error:
message: Channel updated.

This shows no message....

Here's the value when submitting the video form, with blank fields.

From: videoform
option: channel
error: Empty Fields: all fields required.
message:

The data above shows the same error to appear in both forms, but should only appear in the video form.

Here's the code for the conditionals.

The skinning form message handle


         if(!empty($error) && $option == "channel" && $form == 'basicinfo'){
         
             echo '<br/><div id="regFormError" style="visibility:visible; display: block;" class="alert alert-warning">
                     <a class="close" data-dismiss="alert">×</a>
                     <strong>Warning!</strong><span id="errorOuput"> '.$error.'</span>
                   </div>';

          }else if(!empty($message) && $option == "channel" && $form == 'basicinfo')
          {
          
             echo '<br/><div id="regFormError" style="visibility:visible; display: block;" class="alert alert-success">
                     <a class="close" data-dismiss="alert">×</a>
                     <strong>Success!</strong><span id="errorOuput"> '.$message.'</span>
                   </div>';
          
          
          
          }


The video form message handle.



  if(!empty($error) && $option == "channel" && $form == 'videoform'){
         
             echo '<br/><div id="regFormError" style="visibility:visible; display: block;" class="alert alert-warning">
                     <a class="close" data-dismiss="alert">×</a>
                     <strong>Warning!</strong><span id="errorOuput"> '.$error.'</span>
                   </div>';

          }else if(!empty($message) && $option == "channel" && $form == 'videoform')
          {
          
             echo '<br/><div id="regFormError" style="visibility:visible; display: block;" class="alert alert-success">
                     <a class="close" data-dismiss="alert">×</a>
                     <strong>Success!</strong><span id="errorOuput"> '.$message.'</span>
                   </div>';
          
          
          
          }


Please help. Can't for the life of me get to the bottom of this...

Thanks,
Jeremy.

Post a Reply

Replies

Oldest  Newest  Rating
0 Jeremy Benson · November 13, 2014
This solved. I put the code in test files to see if they would work in a refined space. The if statements fired fine. I found out that I was editing the if statement in the wrong file. The actual file had two identical statements...

Sorry for the mixup...
  • 1

PHP

106,928 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators