• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Invalid Request Variable?

#1
[eluser]Bl4cKWid0w[/eluser]
I am musing the form validation class on one of my pages. Everything works fine until I submit the form. When the form submits, the only thing that shows up on my page is a message that says "Invalid request variable.". I have never seen this and am very confused by the message. Does anyone have any ideas as to what may be causing this to happen?

#2
[eluser]Phil Sturgeon[/eluser]
Submitting over POST or GET? Can you show us your form HTML? Also, can you output the POST/GET variable before you get this message, is the data coming through?

#3
[eluser]Bl4cKWid0w[/eluser]
Code:
$clanQuery = $this->db->query("SELECT * FROM clans WHERE clanID = '".$this->uri->segment(3)."'");
             $clan = $clanQuery->row();
             $data['clanID'] = $clan->clanID;
             $data['clanName'] = $clan->clanName;
             $data['clanMotto'] = $clan->clanMotto;
             $data['clanLogo'] = $clan->clanLogo;
             $data['clanWebsite'] = $clan->clanWebsite;
             $data['clanEmail'] = $clan->clanEmail;
             $data['clanAIM'] = $clan->clanAIM;
             $data['clanMSN'] = $clan->clanMSN;
             $data['wins'] = $clan->wins;
             $data['losses'] = $clan->losses;
             $data['rank'] = $clan->rank;
             $data['prev'] = $clan->previous;
             $data['exp'] = $clan->experience;
             $data['joinDate'] = $clan->joinDate;
             $data['memberQuery'] = $this->db->query("SELECT * FROM clan_members WHERE clanID = '".$this->uri->segment(3)."' ORDER BY role");
          
          $this->load->library('form_validation');
          
          $this->form_validation->set_rules('clanLogo','Clan logo','xss_clean');
          $this->form_validation->set_rules('clanMotto','Clan motto','required|min_length[5]|max_length[250]');
          $this->form_validation->set_rules('clanWebsite','Clan website','prep_url');
          //$this->form_validation->set_rules('memberName','Member name','callback_userinv');
          
          if($this->form_validation->run() == FALSE){
          
                $this->load->view('clan_manage', $data);
                
         } else {
        
         $update = $this->db->query("UPDATE clans SET clanMotto='".$this->input->post('clanMotto')."',clanWebsite='".$this->input->post('clanWebsite')."',
              clanAIM='".$clanAIM."',clanMSN='".$clanMSN."' WHERE clanID = '".$this->uri->segment(3)."'");
              
          if($this->input->post('memberName')){
            
            $query = $this->db->query("SELECT * FROM members WHERE memberName = '".$this->input->post('memberName')."'");
            $member = $query->row();
            $memberID = $member->ID_MEMBER;
              $query2 = $this->db->query("SELECT * FROM clans WHERE clanID = '".$this->uri->segment(3)."'");
              $clan = $query2->row();
              $clanLadder = $clan->ladderID;
              $clanID = $clan->clanID;
              if($this->input->post('role') == 1){
                  $roleName = "Member";
              }
              if($this->input->post('role') == 2){
                  $roleName = "Recruiter";
              }
              if($this->input->post('role') == 3){
                  $roleName = "Captain";
              }
              if($this->input->post('role') == 4){
                  $roleName = "Co-Leader";
              }
              $addmember = $this->db->query("INSERT INTO clan_invites(clanID,senderID,role,sendDate,recipientID)
                  VALUES('".$clanID."', '".$context['user']['id']."', '".$this->input->post('role')."', '".date('o-m-d')."', '".$memberID."')");
                  $data['message'] = "Your changes have been saved successfully. ".$this->input->post('memberName')." has been invited to join your clan as a ".$roleName.".";
                  
         } else {
            $data['message'] = "Your changes have been saved successfully.";
         }
        
         $data['heading'] = "Changes Saved";
         $this->load->view('error_view', $data);
        
         }

#4
[eluser]Bl4cKWid0w[/eluser]
bump

#5
[eluser]Bl4cKWid0w[/eluser]
bump

#6
[eluser]iainco[/eluser]
[quote author="thepyromaniac" date="1228171420"]Can you show us your form HTML?[/quote]

#7
[eluser]Bl4cKWid0w[/eluser]
Code:
<div id='body-large'>
<div class='top'>
<h1>&lt;?=$clanName; ?&gt;<small>(&lt;?=anchor($baseURL."challenge/".$clanID, "Challenge"); ?&gt;) (&lt;?=anchor($baseURL."clans/manage/".$clanID, "Manage"); ?&gt;)</small></h1>
<small style='padding: 0px 0px 0px 15px;'>&lt;?=anchor($baseURL, "Storm Gaming Home"); ?&gt; » &lt;?=anchor($baseURL."clans", "Clans"); ?&gt; » &lt;?=anchor($baseURL."clans/".$clanID, $clanName); ?&gt;</small></div>
&lt;?php
$hidden = array('clanID', $this->uri->segment(3));
echo form_open_multipart($baseURL."clans/manage/".$clanID,'',$hidden); ?&gt;
<table align='center' cellspacing='1' cellpadding='0' border='0' id='clantable'>
<tr>
<td colspan='2'><img src='&lt;?=$clanLogo; ?&gt;' width='100' height='100' alt='&lt;?=$clanName; ?&gt;' border='0'>
                &lt;?=form_upload('clanLogo'); ?&gt;</td>
</tr><tr>
<td align='center' colspan='2'>Clan Motto: <br>&lt;?php if(($type == "admin") or ($type == "leader")) echo "&lt;input type='text' name='clanMotto' value='$clanMotto'&gt;"; ?&gt;</td>
</tr><tr>
<td align='right' width='50%'>Wins: &lt;?=$wins; ?&gt;</td>
<td align='left' width='50%'>Exp: &lt;?=$exp; ?&gt;</td>
</tr><tr>
<td align='right' width='50%'>Losses: &lt;?=$losses; ?&gt;</td>
<td align='left' width='50%'>Website:<br>&lt;?php if(($type == "admin") or ($type == "leader")) echo "&lt;input type='text' name='clanWebsite' value='$clanWebsite'&gt;"; ?&gt;</td>
</tr><tr>
<td align='right' width='50%'>Clan AIM: &lt;?=$clanAIM; ?&gt;<br>&lt;?php if(($type == "admin") or ($type == "leader")) echo "&lt;input type='text' name='clanAIM' value='$clanAIM'&gt;"; ?&gt;</td>
<td align='left' width='50%'>Clan MSN: &lt;?=$clanMSN; ?&gt;<br>&lt;?php if(($type == "admin") or ($type == "leader")) echo "&lt;input type='text' name='clanMSN' value='$clanMSN'&gt;"; ?&gt;</td>
</tr>
</table>

<div style='text-align: center'><h1>Clan Roster<h1></div>
<table align='center' cellspacing='1' cellpadding='0' border='0' id='clantable'>
<tr>
<td align='right' width='10%'>Status</td>
<td align='center' width='30%'>Member Name</td>
<td align='center' width='20%'>Clan Role</td>
<td align='center' width='10%'>Clan Exp</td>
<td align='center' width='15%'>Join Date</td>
<td align='center' width='15%'>Contact</td>
</tr><tr>

&lt;?php foreach($memberQuery->result() as $roster){
$memberID = $roster->memberID;
$query = $this->db->query("SELECT * FROM smf_members WHERE ID_MEMBER = '".$memberID."'");
$member = $query->row();
$memberName = $member->memberName; ?&gt;
<td align='right' width='10%'>Active</td>
<td align='center' width='30%'>&lt;?=anchor($baseURL.'forums/index.php?action=profile;u='.$memberID, $memberName); ?&gt;</td>
<td align='center' width='20%'>&lt;?=$roster->role; ?&gt;</td>
<td align='center' width='10%'>&lt;?=$roster->experience; ?&gt;</td>
<td align='center' width='15%'>&lt;?=$roster->joinDate; ?&gt;</td>
<td align='center' width='15%'>&lt;?=mailto($member->emailAddress, 'Email'); ?&gt;</td>
</tr><tr>
&lt;?php }
if(($type == "leader") OR ($type == "co-leader") OR ($type == "captain") OR ($type == "recruiter")) {?&gt;
<td align='center' width='100%' colspan='6'>Recruit New Member</td>
</tr><tr>
<td align='right' width='60%' colspan='3'>&lt;input type='text' name='memberName'&gt;&lt;/td>
<td align='center' width='25%' colspan='2'><select name='role'>
                                        <option value='4'>Co-Leader</option>
                                        <option value='3'>Captain</option>
                                        <option value='2'>Recruiter</option>
                                        <option SELECTED value='1'>Member</option>
                                        </select>
<td align='center' width='15%'>&lt;input type='submit' value='Save' name='save'&gt;&lt;/td>
&lt;?php
}
?&gt;
</tr>                                                                              
</table>

<div class='bottom'></div>
</div>

#8
[eluser]iainco[/eluser]
As far as I can tell you have not closed your form.

Try adding "&lt;/form&gt;" after the submit button.

#9
[eluser]iainco[/eluser]
Also, you seem to be calling DB queries inside your view file, which is bad practice, you should have a model do the DB work for you and return results to the controller which then passes the data into your view file.

#10
[eluser]Bl4cKWid0w[/eluser]
I tried both. Neither worked.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.