Retrieve data from mySQL into directory

Hey guys, any help at all on this would be most appreciated!

I’m having a problem at the moment running a registration form - what I want to do is have a user sign up, so that when they submit their registration form it takes the ID (auto incremented) of the user and forms a directory under members/clubs/$member_id - the code I think is right is below, but any help would be most appreciated!

//Start session

//Include database connection details

//Array to store validation errors
$errmsg_arr = array();

//Validation error flag
$errflag = false;

//Connect to mysql server
$link = mysql_connect(REMOVED, REMOVED, REMOVED);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());

//Select database
$db = mysql_select_db(gafferzo_clubdatabase);
if(!$db) {
	die("Unable to select database");

//Function to sanitize values received from the form. Prevents SQL injection
function clean($str) {
	$str = @trim($str);
	if(get_magic_quotes_gpc()) {
		$str = stripslashes($str);
	return mysql_real_escape_string($str);

//Sanitize the POST values
$fname = clean($_POST['fname']);
$lname = clean($_POST['lname']);
$login = clean($_POST['login']);
$password = clean($_POST['password']);
$cpassword = clean($_POST['cpassword']);
$clubname = clean($_POST['clubname']);

//Input Validations
if($fname == '') {
	$errmsg_arr[] = 'First name missing';
	$errflag = true;
if($lname == '') {
	$errmsg_arr[] = 'Last name missing';
	$errflag = true;
if($login == '') {
	$errmsg_arr[] = 'Login ID missing';
	$errflag = true;
if($password == '') {
	$errmsg_arr[] = 'Password missing';
	$errflag = true;
if($cpassword == '') {
	$errmsg_arr[] = 'Confirm password missing';
	$errflag = true;
if($clubname == '') {
	$errmsg_arr[] = 'Club name missing';
	$errflag = true;
if( strcmp($password, $cpassword) != 0 ) {
	$errmsg_arr[] = 'Passwords do not match';
	$errflag = true;

//If there are input validations, redirect back to the registration form
if($errflag) {
	$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
	header("location: register-form.php");

//Create INSERT query
$qry = "INSERT INTO members(firstname, lastname, login, passwd, clubname) 

$result = @mysql_query($qry);

//Check whether the query was successful or not
if($result) {
	header("location: register-success.php");
}else {
	die("Query failed");

//Fetch club ID
$result = mysql_query("SELECT * FROM clubdatabase");
$row = mysql_fetch_array( $result );
mkdir('/home/gafferzo/www/members/clubs/$row['member_id']', 0777);


Any help on this at all would be greatly appreciated :slight_smile:

Long story short I’ve decided to get this so that when a user activates their email it creates a directory with their member ID - I have the code here but the directory created is literally “/members/clubs/$query”, where it should be more like “/members/clubs/174”

I have code here, any help would be most appreciated!

[php] //Create directory
$queryString = $_SERVER[‘QUERY_STRING’];
$query = “SELECT member_id FROM members WHERE $queryString=$row[activation]”;
$path = ‘/home/gafferzo/www/members/clubs/{$query}’;

if(mkdir($path, 0777))
echo "Directory has been created successfully...";
echo "Failed to create directory...";
} [/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service