Welcome Guest, Not a member yet? Register   Sign In
i want to insert an email in database where this email not exist
#1

[eluser]MrAmine[/eluser]
hi evryone
i want to insert an email in database where this email not exist
how can i do
#2

[eluser]InsiteFX[/eluser]
Some thing like this, Not tested!
Code:
public function insert_email($email)
{
    // do a check here to make sure that you have a valid emil address in $email
    // or ( better --> ) before you pass it to this function!

    // check to see if the email is already in the database table
    $this->db->where('email_addr', $email);
    $query = $this->db->get('email_table');

    if ($query->num_rows() == 1)
    {
        // $email exists!
        return TRUE;
    }
    else
    {
        // $email doe's not exist so we insert it!
        $data = array(
            'email_addr' => $email
        );

        $this->db->insert('email_table', $data);
        return FALSE;
    }
}

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB