Ckeck if user email is listed in database

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
Dlan
Registered User
Posts: 19
Joined: Tue Apr 17, 2018 1:25 pm

Ckeck if user email is listed in database

Post by Dlan »

I’m not sure if I’m posting this to the correct place or not, but here it is..

I’ve been using a simple membership on my site for years. I’ve just installed BB3. I’m slowly moving everyone over to BB membership. I’m looking to set it up so once people have logged in to BB they will be able to use rest of the site as before. I think I’ve most of it figured out but I’m getting stuck on checking if their email is in the BB database.

This is what I have, but it ‘just did not work’. Could someone tell me what is wrong

Code: Select all

con_db_BB3.php:
$con = mysqli_connect($dbhost, $dbusername, $dbpasswd, $db_name) or die("Couldn't connect to data base in con_db_BB3");
-----
include 'inc/con_db_BB3.php';

if (isset($_POST['email_address']))    
{    
$email_address = $_POST['email_address'];              
}  
if(!$email_address)
{
	echo "<h2 align=\"center\">Please enter your email address </h2><br>";
	exit();
}

 if (!$con) {
  	die("Connection failed : " . mysqli_error());
 }

  
$query = mysqli_query($con, "SELECT *  FROM phpbb_users WHERE user_email = ' $email_address ' ") or die ("just did not work <br>" . mysqli_error($con));
  
 if(mysqli_num_rows($query) > 0)
 {
    echo "email  exists";
	$MEMB = 1;  //is member
}else{ 
 	echo "cant find email ";
 	$MEMB = 0;  //is not member
} 
 exit();  
 ?> 
Thanks in advance, Don..

[Spam link removed]
Last edited by Mick on Fri May 11, 2018 9:42 am, edited 1 time in total.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3738
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: Ckeck if user email is listed in database

Post by Kailey »

Maybe this?

Code: Select all

mysqli_query($con, "SELECT * FROM phpbb_users WHERE user_email = '$email_address'") or die ("just did not work <br>" . mysqli_error($con));
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
My little corner of the world, where I sometimes post things documented from my job.
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 28654
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Ckeck if user email is listed in database

Post by Paul »

please make sure to escape $email_address as this script is curdently vulnarble to sql injection.
User avatar
AmigoJack
Registered User
Posts: 6113
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Ckeck if user email is listed in database

Post by AmigoJack »

Dlan wrote: Fri May 11, 2018 1:56 am

Code: Select all

' $email_address '
E-mail addresses are never stored with a leading and a trailing space - remove them and be aware of user input like

Code: Select all

'; DROP DATABASE;'
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Dlan
Registered User
Posts: 19
Joined: Tue Apr 17, 2018 1:25 pm

Re: Ckeck if user email is listed in database

Post by Dlan »

Yep, that fixed it..
Thanks for your help

Don...
Post Reply

Return to “phpBB Custom Coding”