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,
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())";
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,
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.
ok i got someone to fix the code:
<?php
//Connect to database
mysql_connect ( host, username, pass)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,
sorry heres the code, had to add some things in:
<?php
//Connect to database
mysql_connect ( host, username, pass)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";
?>