![]() |
I have created code to import gmail contact. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: I have created code to import gmail contact. (/showthread.php?tid=37511) |
I have created code to import gmail contact. - El Forum - 01-12-2011 [eluser]Unknown[/eluser] Model: import_contact.php <?php class import_contact extends Model { function __construct(){ parent::Model(); } function insertEmail($username,$password) { $sql = "INSERT INTO email_record (`email`,`password`) values(?,?) "; $query = $this->db->query($sql, array($username,$password)); return $this->db->insert_id(); } function insertContact($id,$name,$email) { $sql = "INSERT INTO contact_list (`email`,`name`,`email_id`) values(?,?,?) "; $query = $this->db->query($sql, array($email,$name,$id)); //return $query; return $query; } function getContact($num, $offset) { $query = $this->db->get('contact_list', $num, $offset); //return $query; return $query->result_array(); } } ?> Table Structure: CREATE TABLE IF NOT EXISTS `contact_list` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `email_id` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `email_record` ( `id` int(11) NOT NULL AUTO_INCREMENT, `email` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `email` (`email`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; View: import_contact.php <?php echo form_open('import/import_contact');?> <div class="code"> Please enter only gmail username/password. <div class="label">Username</div> <div class="field"> <?php $data = array( 'name' => 'username', 'id' => 'username', 'value' => set_value('username'), 'maxlength' => '100', 'size' => '50', 'style' => 'width:230px', ); echo form_input($data); ?> </div> <div style="clear:both;"></div> <div class="label">Password</div><div class="field"><?php $data = array( 'name' => 'password', 'id' => 'password', 'value' => '', 'maxlength' => '100', 'type' => 'password', 'size' => '50', 'style' => 'width:230px', ); echo form_input($data); ?> </div> <div style="clear:both;"></div> <div class="button"><?php echo form_submit('import', 'Get Contact'); ?></div> <div style="clear:both;"></div> </div> <?php $list=""; $list.="<div class='mainDiv'><div class='namehead'>Name</div><div class='emailhead'>Email</div><div style='clear:both'></div>"; if(count($emailLists)>0){ foreach($emailLists as $contactlist){ $name=empty($contactlist['fullName'])?$contactlist['name']:$contactlist['fullName']; $email=empty($contactlist['email'])?$contactlist['email_3']:$contactlist['email']; $list.="<div style='clear:both'></div><div class='name'>".(empty($name)?"-":$name)."</div><div class='emailvalue'>".$email."</div><div style='clear:both'></div>"; } $list.='</div>'; echo $list; echo '<div style="padding-top:10px;"> '.$this->pagination->create_links().'</div>'; } ?> |