wmguk Posted March 10, 2010 Share Posted March 10, 2010 Hi, I've been looking at some codes and I noticed this: public function graphicMailReg($email) { $this->load->library("Curl"); $url = "https://www.graphicmail.co.uk/api.aspx"; $vals = array(); $vals['Username'] = "XXXX"; $vals['Password'] = "XXXX"; $vals['Function'] = "post_subscribe"; $vals['SID'] = '6'; $vals['Email'] = $email; $vals['MailingListID'] = XXX; $curl = new Curl(); $output = $this->curl->doPost($url, $vals); $outArr = explode("|",$output); return $outArr[0]; } how do I call this? I am passing a variable called $email to the page, so i need this to load it up Link to comment https://forums.phpfreaks.com/topic/194779-calling-a-function/ Share on other sites More sharing options...
gwolgamott Posted March 10, 2010 Share Posted March 10, 2010 $my_returned = graphicMailReg($email); // $my_returned will be equal to $outArr[0]; from the function. Hi, I've been looking at some codes and I noticed this: public function graphicMailReg($email) { $this->load->library("Curl"); $url = "https://www.graphicmail.co.uk/api.aspx"; $vals = array(); $vals['Username'] = "XXXX"; $vals['Password'] = "XXXX"; $vals['Function'] = "post_subscribe"; $vals['SID'] = '6'; $vals['Email'] = $email; $vals['MailingListID'] = XXX; $curl = new Curl(); $output = $this->curl->doPost($url, $vals); $outArr = explode("|",$output); return $outArr[0]; } how do I call this? I am passing a variable called $email to the page, so i need this to load it up Link to comment https://forums.phpfreaks.com/topic/194779-calling-a-function/#findComment-1024229 Share on other sites More sharing options...
jl5501 Posted March 10, 2010 Share Posted March 10, 2010 The function as shown is intented to be part of a class, so you will need to build a class around it, create an instance of the class, then call the function on that class instance. Link to comment https://forums.phpfreaks.com/topic/194779-calling-a-function/#findComment-1024231 Share on other sites More sharing options...
wmguk Posted March 10, 2010 Author Share Posted March 10, 2010 ok, so I have this: $('#keep-updated').click(function() { $.post("<?php echo FC ?>/home/emailSignup/", {email: $('#email').val()}, function(data){ $('#main').css('display','none'); $('#main2').css('display','block'); }, "json"); }); public function emailSignup() { $code = md5(time()."SNIP"); $sql = "insert into emailSignup (email, location,status,verifyCode) values (?,1,0,?)"; $this->db->query($sql,array($_POST['email'],$code)); // send verify code to user $link = FC."/home/userVerify/$code/"; list($subject,$text) = $this->common->getEmailTemplate('VERIFY_LINK'); $text = str_replace('{VERIFY_LINK}',$link,$text); $this->user->sendEmail($text, "", $subject, "Snippa.co.uk", "[email protected]", $_POST['email'], ""); $this->user->setCookie('visit','registered'); echo "1"; exit; } public function userVerify() { $this->data['title'] = 'Sign Up'; $this->data['footer'] = $this->common->getFooter(); if (!strlen($this->uri->segment(3))) { header("Location: ".FC); exit; } $sql = "select email, status from emailSignup where verifyCode = ?"; $i = $this->db->query($sql,array($this->uri->segment(3))); $this->data['status'] = 0; if ($i->num_rows) { $row = $i->result(); if ($row[0]->status == '0') { $emailRet = $this->user->graphicMailReg($row[0]->email); $this->db->query("update emailSignup set status = ? where verifyCode = ?",array($emailRet,$this->uri->segment(3))); $this->data['status'] = 1; } else { $this->data['status'] = 2; } } } Does this make more sense? Link to comment https://forums.phpfreaks.com/topic/194779-calling-a-function/#findComment-1024241 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.