Jump to content

calling a function


wmguk

Recommended Posts

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

$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

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

Archived

This topic is now archived and is 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.