Bridging username, password , name , email address only on register form. Bridging username, password , name , email address only on register form.
 

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]

Main Menu

Bridging username, password , name , email address only on register form.

Started by just_some_guy, August 04, 2007, 09:35:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

just_some_guy

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.



$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,
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

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


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

just_some_guy

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

So would this work?


$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,
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

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.

just_some_guy

ok i got someone to fix the code:

<?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,
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

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

<?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";
?>
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