Jump to content

[SOLVED] add code to code


fullyloaded

Recommended Posts

hi

any one know how i can add code 1 to code 2 witch is below?what im trying to do is have a banned email code so when some one signs up it will say the email has been banned i have a table in my database with the list of emails that i want banned its called banned_emails and iin the banned emails table its called banned_email that is where the emails are please help

 

code 1 :

$this->dbu->query("select banned_email from banned_emails where email='".$ld['email']."'");

code 2 :

if(!$ld['email'])
	{
		$ld['error'].="Please fill in the 'Email Address' field."."<br>";
		$is_ok=false;
	}
	elseif(!secure_email($ld['email']))
	{
		$ld['error'].="Please provide a valid email address."."<br>";
		$is_ok=false;
	}
	elseif(!$allowed_email[$ld['email']])
	{
		$this->dbu->query("select members_id from members where email='".$ld['email']."'");

		if($this->dbu->move_next())
		{
			$ld['error'].="This email address is already registered."."<br>";
			$is_ok=false;
		}
	}

Link to comment
https://forums.phpfreaks.com/topic/43606-solved-add-code-to-code/
Share on other sites

Is this what you want?

 

if(!$ld['email'])
	{
		$ld['error'].="Please fill in the 'Email Address' field."."<br>";
		$is_ok=false;
	}
	elseif(!secure_email($ld['email']))
	{
		$ld['error'].="Please provide a valid email address."."<br>";
		$is_ok=false;
	}
	elseif(!$allowed_email[$ld['email']])
	{
		$this->dbu->query("select members_id from members where email='".$ld['email']."'");

		if($this->dbu->move_next())
		{
			$ld['error'].="This email address is already registered."."<br>";
			$is_ok=false;
		}

		$this->dbu->query("select banned_email from banned_emails where email='".$ld['email']."'");

		if($this->dbu->move_next())
		{
			$ld['error'].="This email address is banned.  Please contact the administrator."."<br>";
			$is_ok=false;
		}
	}

hi yeah like that but im getting this error any idea why?

Process Halted!
Error:db::query() failed.ERROR MESSAGE IS: Failed to run Query:select banned_email from banned_emails where email='[email protected]' Unknown column 'email' in 'where clause'

 

Unknown column 'email' in 'where clause'

This means that ur database field name is not matching with ur query column.

email will be something other in ur database check it and redo it in ur query.

hi this is what the table looks like in my database is there any way to make this code work with the table?

 

code :

$this->dbu->query("select banned_email from banned_emails where email='".$ld['email']."'");

if($this->dbu->move_next())

{

$ld['error'].="This email address is banned.  Please contact the administrator."."<br>";

$is_ok=false;

}
}

 

database table :

-- 
-- Table structure for table `banned_emails`
-- 

CREATE TABLE `banned_emails` (
  `banned_emails` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- 
-- Dumping data for table `banned_email`
-- 

INSERT INTO `banned_email` VALUES ('[email protected]');

hi this is what the table looks like in my database is there any way to make this code work with the table?

 

code :

$this->dbu->query("select banned_email from banned_emails where email='".$ld['email']."'");

if($this->dbu->move_next())

{

$ld['error'].="This email address is banned.  Please contact the administrator."."<br>";

$is_ok=false;

}
}

 

database table :

-- 
-- Table structure for table `banned_emails`
-- 

CREATE TABLE `banned_emails` (
  `banned_emails` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- 
-- Dumping data for table `banned_email`
-- 

INSERT INTO `banned_email` VALUES ('[email protected]');

 

 

$this->dbu->query("select banned_email from banned_emails where banned_emails='".$ld['email']."'");

if($this->dbu->move_next())

{

$ld['error'].="This email address is banned.  Please contact the administrator."."<br>";

$is_ok=false;

}
}

Try this.

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.