473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

php folder create

hi

i have created a script that creates a user in a mysql db and i need it to create a folder for that user. the snipit of code that should do this i think is this

mkdir("/var/www/hosts/$full_name");

it is suposed to create a folder called the full name of a user entered into a form
can anyone please tell me what i am doing wrong
p.s i have made sure the perms are correct
Feb 1 '09 #1
4 4160
Markus
6,050 Expert 4TB
Turn on debugging messages.

Also, post the code you use. It may be a problem elsewhere.
Feb 1 '09 #2
sorry im relly new to php
heres the fulll code
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. session_start();
  3.  
  4.  
  5. include ('dbc.php'); 
  6.  
  7.  
  8. if ($_POST['Submit'] == 'Register')
  9. {
  10.    if (strlen($_POST['email']) < 5)
  11.    {
  12.     die ("Incorrect email. Please enter valid email address..");
  13.     }
  14.    if (strcmp($_POST['pass1'],$_POST['pass2']) || empty($_POST['pass1']) )
  15.     { 
  16.     //die ("Password does not match");
  17.     die("ERROR: Password does not match or empty..");
  18.  
  19.     }
  20.     if (strcmp(md5($_POST['user_code']),$_SESSION['ckey']))
  21.     { 
  22.              die("Invalid code entered. Please enter the correct code as shown in the Image");
  23.           } 
  24.     $rs_duplicates = mysql_query("select id from users where full_name='$_POST[full_name]'");
  25.     $duplicates = mysql_num_rows($rs_duplicates);
  26.  
  27.     if ($duplicates > 0)
  28.     {    
  29.     //die ("ERROR: Account already exists.");
  30.     header("Location: register.php?msg=ERROR: Account already exists..");
  31.     exit();
  32.     }
  33.  
  34.  
  35.     $md5pass = md5($_POST['pass2']);
  36.     $activ_code = rand(1000,9999);
  37.     $server = $_SERVER['HTTP_HOST'];
  38.     $host = ereg_replace('www.','',$server);
  39.     mkdir("/var/www/hosts/.$full_name.");
  40.     mysql_query("INSERT INTO users
  41.                   (`user_email`,`user_pwd`,`country`,`joined`,`activation_code`,`full_name`)
  42.                   VALUES
  43.                   ('$_POST[email]','$md5pass','$_POST[country]',now(),'$activ_code','$_POST[full_name]')") or die(mysql_error());
  44.  
  45.     $message = 
  46. "Thank you for registering an account with $server. Here are your login details...\n\n
  47. Your domain: $_POST[full_name] \n
  48. Password: As posted
  49. Activation Code: $activ_code \n
  50. ____________________________________________
  51. *** ACTIVATION LINK ***** \n
  52. Activation Link: http://$server/activate.php?usr=$_POST[email]&code=$activ_code \n\n
  53. _____________________________________________
  54. Thank you. This is an automated response. PLEASE DO NOT REPLY.
  55. ";
  56.  
  57.     mail($_POST['email'] , "Login Activation", $message,
  58.     "From: \"Auto-Response\" <notifications@$host>\r\n" .
  59.      "X-Mailer: PHP/" . phpversion());
  60.     unset($_SESSION['ckey']);
  61.     echo("Registration was Successful! An activation code has been sent to your email address with an activation link...");    
  62.  
  63.     exit;
  64.     }    
  65.  
  66. ?>
  67.  
here is the error msg i get
Notice: Undefined variable: full_name in /var/www/hosts/www.easehosting.co.uk/docs/register.php on line 39

Warning: mkdir() [function.mkdir]: File exists in /var/www/hosts/www.easehosting.co.uk/docs/register.php on line 39
thank you
Feb 1 '09 #3
Atli
5,058 Expert 4TB
Hi.

Apparently, the $full_name variable is undefined, meaning that it doesn't exist before you try to use it.

If the value for this is coming from a HTML form, then you would most likely have to fetch it from the $_POST array before you use it. (Like your code does with all the other form values).

I would also advice you to validate the input before using it.
Currently you are simply passing the user input into your code without even checking to see if the values exist.
You should make sure the values exists, and that they are what you expect them to be, or your web will be vulnerable to all sorts of security threats. Like SQL Injection.
Feb 1 '09 #4
thank you that was a big help
Feb 2 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mikedi | last post by:
Hi. I use Exchange Server and I need to create a lot of rules to control my incomming mail. I also need be able to check my mailbox from any PC connected to the net. However there is only 32Kb of...
1
by: trialproduct2004 | last post by:
Hi all I am having one application where i want to implement new feature that is 'create new folder'. and display new folder name in listview. My listview is editable. My problem is i want to...
6
by: jzdeng | last post by:
Hi, All I use VS 2005 to create a web service. The web service is used to create a sheared folder. It works fine we I run it from VS 2005. But, when I move it to inetpub, it does not work...
8
by: Paw | last post by:
Greetings. I use asp. what I need is is when a visitor comes to the site, I need it to check the host name. if "www.hometowndigest.com" is the host, then check a folder named "something" and if...
0
by: 1333 | last post by:
I need to create a new folder every time the upload folder has 10 files uploaded to it. So when folder1 has 10 files, folder2 is created and becomes the upload folder, and when it has 10 files...
10
by: kai | last post by:
Hi, All I am trying to create a file folder for any login user, and create sub folders for the user on a web page. After the user login again, he can only sees his own folder on the Web page. I am...
5
by: IUnknown | last post by:
Ok, we are all aware of the situation where modifying the folder structure (adding files, folders, deleting files, etc) will result in ASP.NET triggering a recompilation/restart of the application....
5
by: Sin Jeong-hun | last post by:
Hello. Speical folders, like Desktop, usually have different display names. For example, in Japanese Windows, it's displayed as "$B%G%9%/%H%C%W(B". I want to get the this displayed name of a...
5
by: krasman | last post by:
hi everyone, i hope you might help me on this one. i need to create a contact in a exchange public folder using dotnet (vb or c#) and exchange 2003, without using outlook object model. i'm...
4
lee123
by: lee123 | last post by:
Hi there i was wondering how you make a folder in code to place a text document. another words, i want to create a folder for a text file i create so when iim done with writing the txt file it will...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.