Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Bridging username, password , name , email address only on register form.  (Read 6693 times)

0 Members and 1 Guest are viewing this topic.

just_some_guy

  • Supporter
  • Coppermine addict
  • ****
  • Offline Offline
  • Posts: 539
  • I am currently on holiday, back in a few weeks. :D

Hello,

Sorry i cant post any of the required urls, i have not uploaded the files yet.

I am planning on using coppermine inside a website that already requires a login/register.

Could i use the code below , which is from a script i used in the exisiting login/register form.

This is the register file. What fields are in the coppermine tables? and i am looking to intergarate the register for my current register/login system with the coppermine one, is this possible with the method i have outlined? if the are corrections needed please let me know.

Code: [Select]

$checkuser = mysql_query("SELECT username FROM coppermine WHERE username='$username'");

$username_exist = mysql_num_rows($checkuser);

if($username_exist > 0){
    echo "I'm sorry but the username you specified has already been taken.  Please pick another one.";
    unset($username);
    include 'register.html';
    exit();
}

// lf no errors present with the username
// use a query to insert the data into the database.

$query = "INSERT INTO coppermine (name, email, username, password)
VALUES('$name', '$email', '$username', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();

echo "You have successfully Registered";

thanks,
Logged
Tambien, Hablo Espaņol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Nibbler

  • Guest

Are you are just looking to auto-register accounts with Coppermine as opposed to actual bridging?

user_name, user_email, user_password

user_password is an MD5 hash of the actual password, you need to mark the user as active, and you should include the date of registration, so

Code: [Select]
$query = "INSERT INTO coppermine (user_name, user_email, user_password, user_active, user_regdate) VALUES ('$username', '$email', MD5('$password'), 'YES', NOW())";
Logged

just_some_guy

  • Supporter
  • Coppermine addict
  • ****
  • Offline Offline
  • Posts: 539
  • I am currently on holiday, back in a few weeks. :D

Yes i want to auto register for coppermine, but i also want to register for my website in the process.

So would this work?


Code: [Select]
$checkuser = mysql_query("SELECT username FROM coppermine WHERE username='$username'");

$username_exist = mysql_num_rows($checkuser);

if($username_exist > 0){
    echo "I'm sorry but the username you specified has already been taken.  Please pick another one.";
    unset($username);
    include 'register.html';
    exit();
}

// lf no errors present with the username
// use a query to insert the data into the database.

$query = "INSERT INTO coppermine (name, email, username, password)
VALUES('$name', '$email', '$username', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();

}

$query = "INSERT INTO coppermine (user_name, user_email, user_password, user_active, user_regdate) VALUES ('$username', '$email', MD5('$password'), 'YES', NOW())";
echo "You have successfully Registered";

Would the above code (modified from the previous code) work and register with the correct details to the existing login system and coppermine?

Ps the fields on the register form are name,email,username,password.

Thanks,
Logged
Tambien, Hablo Espaņol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

Nibbler

  • Guest

No, because your code makes no sense. My post was just to give you the idea of what code you need - you will need to modify your script to use it.
Logged

just_some_guy

  • Supporter
  • Coppermine addict
  • ****
  • Offline Offline
  • Posts: 539
  • I am currently on holiday, back in a few weeks. :D

ok i got someone to fix the code:

Code: [Select]
<?php

//Connect to database
mysql_connect hostusernamepass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

$name $_POST['name'];
$email $_POST['email'];    
$username $_POST['username'];
$password md5($_POST['password']);

// lets check to see if the username already exists
$checkuser mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist mysql_num_rows($checkuser);
if(
$username_exist 0) {
    echo 
"I'm sorry but the username you specified has already been taken.  Please pick another one.";
    unset(
$username);
    include 
'register.html';
    exit();
}

// lf no errors present with the username
// use a query to insert the data into the database.

//Insert into `user`
$query "INSERT INTO users (name, email, username, password)
VALUES('
$name', '$email', '$username', '$password')";
mysql_query($query) or die(mysql_error());

//Insert into `coppermine`
$query "INSERT INTO coppermine (name, email, username, password)
VALUES('
$name', '$email', '$username', '$password')";
mysql_query($query) or die(mysql_error());

mysql_close();

echo 
"You have successfully Registered";
?>

I didnt understand your first post, are you saying there is more information required for the coppermin registriation like (user_active, user_regdate) if so how do you find this info out?

Thanks,
Logged
Tambien, Hablo Espaņol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums

just_some_guy

  • Supporter
  • Coppermine addict
  • ****
  • Offline Offline
  • Posts: 539
  • I am currently on holiday, back in a few weeks. :D

sorry heres the code, had to add some things in:

Code: [Select]
<?php

//Connect to database
mysql_connect hostusernamepass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

$name $_POST['name'];
$email $_POST['email'];    
$username $_POST['username'];
$password md5($_POST['password']);

// lets check to see if the username already exists
$checkuser mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist mysql_num_rows($checkuser);
if(
$username_exist 0) {
    echo 
"I'm sorry but the username you specified has already been taken.  Please pick another one.";
    unset(
$username);
    include 
'register.html';
    exit();
}

// lf no errors present with the username
// use a query to insert the data into the database.

//Insert into `user`
$query "INSERT INTO users (name, email, username, password)
VALUES('
$name', '$email', '$username', '$password')";
mysql_query($query) or die(mysql_error());

//Insert into `coppermine`
$query "INSERT INTO coppermine (user_name, user_email, user_password, user_active, user_regdate) //Dont understand the user_active and regdate are they field in the coppermine table?
VALUES ('
$username', '$email', MD5('$password'), 'YES', NOW())";


mysql_close();

echo 
"You have successfully Registered";
?>
« Last Edit: August 05, 2007, 05:17:42 pm by GauGau »
Logged
Tambien, Hablo Espaņol      PHP - Achieve Anything
"The Internet is becoming the town square for the global village of tomorrow. " - Bill Gates
Windows 7 Forums
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 19 queries.