Jump to content

Recommended Posts

friendRequest.php view file

<div id="friendRequestForm">
<fieldset>
<legend>Friend Request: <?=$this->get_user->getName($segment);?></legend>
<?=form_open('friends/addFriend');?>
<?=form_textarea('message', 'Message', 'id="messageArea" rows="1" cols="20"');?>
<?=form_hidden('userID', $this->uri->segment(3)); ?>
<?=form_submit('submit', 'Send Request', 'class="buttons"'); ?>
<?=form_close();?>
</fieldset>
</div>

 

friends.php Construct

    function addFriend(){
        $this->load->model('user_friends');
        if($query = $this->user_friends->sendRequest()){
            $data['message'] = 'Your friend request has been submitted please wait for the user to accept you!';
            $data['main_content'] = 'display';
            $this->load->view('include/template.php', $data);    
        }
        else {
            $data['message'] = 'An error has accurd';
            $data['main_content'] = 'display';
            $this->load->view('include/template.php', $data);
        }

            
    }

 

user_friends model

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class user_friends extends CI_Model {
    
    function acceptFriend(){
        
        
    }
    
    function denyFriend(){
        
        
    }

    function sendRequest(){
        
        $new_member_insert_data = array(
            'toUserID' => $this->input->post('userID'),
            'fromUserID' => $this->session->userdata('userID'),
            'type' => 'friendRequest',
            'text' => $this->input->post('message')
        );
        $insert  = $this->db->insert('notification', $new_member_insert_data);
        return $insert;
        
    }
    
}

 

im getting a duplicate entry to the SQL when i send request

1 is blank

1 is correct info.

Link to comment
https://forums.phpfreaks.com/topic/244364-duplicate-sql-insert/
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.