php folder create

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oliverjohnstone
    New Member
    • Feb 2009
    • 5

    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
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Turn on debugging messages.

    Also, post the code you use. It may be a problem elsewhere.

    Comment

    • oliverjohnstone
      New Member
      • Feb 2009
      • 5

      #3
      sorry im relly new to php
      heres the fulll code
      [code=php]
      <?php
      session_start() ;


      include ('dbc.php');


      if ($_POST['Submit'] == 'Register')
      {
      if (strlen($_POST['email']) < 5)
      {
      die ("Incorrect email. Please enter valid email address..");
      }
      if (strcmp($_POST['pass1'],$_POST['pass2']) || empty($_POST['pass1']) )
      {
      //die ("Password does not match");
      die("ERROR: Password does not match or empty..");

      }
      if (strcmp(md5($_P OST['user_code']),$_SESSION['ckey']))
      {
      die("Invalid code entered. Please enter the correct code as shown in the Image");
      }
      $rs_duplicates = mysql_query("se lect id from users where full_name='$_PO ST[full_name]'");
      $duplicates = mysql_num_rows( $rs_duplicates) ;

      if ($duplicates > 0)
      {
      //die ("ERROR: Account already exists.");
      header("Locatio n: register.php?ms g=ERROR: Account already exists..");
      exit();
      }


      $md5pass = md5($_POST['pass2']);
      $activ_code = rand(1000,9999) ;
      $server = $_SERVER['HTTP_HOST'];
      $host = ereg_replace('w ww.','',$server );
      mkdir("/var/www/hosts/.$full_name.");
      mysql_query("IN SERT INTO users
      (`user_email`,` user_pwd`,`coun try`,`joined`,` activation_code `,`full_name`)
      VALUES
      ('$_POST[email]','$md5pass','$ _POST[country]',now(),'$activ _code','$_POST[full_name]')") or die(mysql_error ());

      $message =
      "Thank you for registering an account with $server. Here are your login details...\n\n
      Your domain: $_POST[full_name] \n
      Password: As posted
      Activation Code: $activ_code \n
      _______________ _______________ ______________
      *** ACTIVATION LINK ***** \n
      Activation Link: http://$server/activate.php?us r=$_POST[email]&code=$activ_co de \n\n
      _______________ _______________ _______________
      Thank you. This is an automated response. PLEASE DO NOT REPLY.
      ";

      mail($_POST['email'] , "Login Activation", $message,
      "From: \"Auto-Response\" <notifications@ $host>\r\n" .
      "X-Mailer: PHP/" . phpversion());
      unset($_SESSION['ckey']);
      echo("Registrat ion was Successful! An activation code has been sent to your email address with an activation link...");

      exit;
      }

      ?>
      [/code]
      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
      Last edited by Atli; Feb 1 '09, 11:30 PM. Reason: Added [code] tags.

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        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.

        Comment

        • oliverjohnstone
          New Member
          • Feb 2009
          • 5

          #5
          thank you that was a big help

          Comment

          Working...