[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?
[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?
[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);
}
[eluser]Bl4cKWid0w[/eluser]
bump
[eluser]Bl4cKWid0w[/eluser]
bump
[eluser]iainco[/eluser]
[quote author="thepyromaniac" date="1228171420"]Can you show us your form HTML?[/quote]
[eluser]Bl4cKWid0w[/eluser]
Code: <div id='body-large'>
<div class='top'>
<h1><?=$clanName; ?><small>(<?=anchor($baseURL."challenge/".$clanID, "Challenge"); ?>) (<?=anchor($baseURL."clans/manage/".$clanID, "Manage"); ?>)</small></h1>
<small style='padding: 0px 0px 0px 15px;'><?=anchor($baseURL, "Storm Gaming Home"); ?> » <?=anchor($baseURL."clans", "Clans"); ?> » <?=anchor($baseURL."clans/".$clanID, $clanName); ?></small></div>
<?php
$hidden = array('clanID', $this->uri->segment(3));
echo form_open_multipart($baseURL."clans/manage/".$clanID,'',$hidden); ?>
<table align='center' cellspacing='1' cellpadding='0' border='0' id='clantable'>
<tr>
<td colspan='2'><img src='<?=$clanLogo; ?>' width='100' height='100' alt='<?=$clanName; ?>' border='0'>
<?=form_upload('clanLogo'); ?></td>
</tr><tr>
<td align='center' colspan='2'>Clan Motto: <br><?php if(($type == "admin") or ($type == "leader")) echo "<input type='text' name='clanMotto' value='$clanMotto'>"; ?></td>
</tr><tr>
<td align='right' width='50%'>Wins: <?=$wins; ?></td>
<td align='left' width='50%'>Exp: <?=$exp; ?></td>
</tr><tr>
<td align='right' width='50%'>Losses: <?=$losses; ?></td>
<td align='left' width='50%'>Website:<br><?php if(($type == "admin") or ($type == "leader")) echo "<input type='text' name='clanWebsite' value='$clanWebsite'>"; ?></td>
</tr><tr>
<td align='right' width='50%'>Clan AIM: <?=$clanAIM; ?><br><?php if(($type == "admin") or ($type == "leader")) echo "<input type='text' name='clanAIM' value='$clanAIM'>"; ?></td>
<td align='left' width='50%'>Clan MSN: <?=$clanMSN; ?><br><?php if(($type == "admin") or ($type == "leader")) echo "<input type='text' name='clanMSN' value='$clanMSN'>"; ?></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>
<?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; ?>
<td align='right' width='10%'>Active</td>
<td align='center' width='30%'><?=anchor($baseURL.'forums/index.php?action=profile;u='.$memberID, $memberName); ?></td>
<td align='center' width='20%'><?=$roster->role; ?></td>
<td align='center' width='10%'><?=$roster->experience; ?></td>
<td align='center' width='15%'><?=$roster->joinDate; ?></td>
<td align='center' width='15%'><?=mailto($member->emailAddress, 'Email'); ?></td>
</tr><tr>
<?php }
if(($type == "leader") OR ($type == "co-leader") OR ($type == "captain") OR ($type == "recruiter")) {?>
<td align='center' width='100%' colspan='6'>Recruit New Member</td>
</tr><tr>
<td align='right' width='60%' colspan='3'><input type='text' name='memberName'></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%'><input type='submit' value='Save' name='save'></td>
<?php
}
?>
</tr>
</table>
<div class='bottom'></div>
</div>
[eluser]iainco[/eluser]
As far as I can tell you have not closed your form.
Try adding "</form>" after the submit button.
[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.
[eluser]Bl4cKWid0w[/eluser]
I tried both. Neither worked.
|