Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    52
    Thanks
    24
    Thanked 0 Times in 0 Posts

    Exclamation Copy files from one folder to another

    I have a script that automates a webpage process but i am stuck with how to copy the files from an existing folder to the newly created folder. and how to edit the content of a single file in the newly created folder

    Any help appreacited


    PHP Code:
    <?php
    // Create connection
    $con mysql_connect("mysql""admin""admin");

    // Check connection
      
    if (!$con)
      {
        die(
    'Could not connect: ' mysql_error());
      }

      
    mysql_select_db("createsite"$con);
     
    if(isset(
    $_POST['submitts'])){

    $name $_POST['Name'];
    $email $_POST['Email'];
    $ZNZOne $_POST['ZNZO'];
    $ZNZBigCash $_POST['ZNZB'];
    $user $_POST['user'];
    $comment $_POST['comment'];
     
      if(empty(
    $name)){
         echo 
    '<p>Please enter your name!</p>';
      }
      if(empty(
    $email)){
         echo 
    '<p>Please enter your email!</p>';
      }
      if(empty(
    $ZNZOne)){
         echo 
    '<p>Please enter ZNZ One Referral ID #!</p>';
      }
      if(empty(
    $ZNZBigCash)){
        echo 
    '<p>Please enter ZNZ Big Cash Referral ID #!</p>';
      }
      if(empty(
    $user)){
        echo 
    '<p>Please enter your desired username!</p>';
      }
      
      
    $dbunames mysql_query("SELECT * FROM znzpage WHERE username='$user'");
      if(
    mysql_num_rows($dbunames) > ) { //check if there is already an entry for that username
          
    echo 'Username is already taken, Please enter a different one.';
        } else {
        
    mysql_query("INSERT INTO znzpage(`id`, `Name`, `Email`, `referralid`, `cashreferralid`, `username`) VALUES ('', '$name', '$email', '$ZNZOne', '$ZNZBigCash', '$user')");
      
        
        
    //Path to where you want to create the new folder
        
    $path "/user/";
        
    $src "/user/1994/"
        
        
    //Complete path to new folder
        
    $d $path $user;
        if( 
    is_dir($d) === false )
        {
        
    mkdir($d0755);
        }

        
    copy($src ."index.html"$d ."/index.html");
        
        
        
    $email_to "$email";
        
    $email_admin "nadogrand@gmail.com";
        
    $email_subject_admin "New affiliate signup!";
        
    $email_subject "Your Custom ZNZ Page is Ready!";
        
        
    $email_message .= "Congratulations!"."\r\n";
        
    $email_message .= "Your custom ZNZ Page is now live and you can start promoting it!"."\r\n";
        
    $email_message .= "The link to your ZNZ Page is:
        http://www.znzadteam.com/user/$user"
    ."\r\n";
        
    $email_message .= "Be sure to check out the training materials on the website to help you understand how to effectively promote your page so that you can get traffic to it and start making money.
        http://www.znzadteam.com/znz-training"
    ."\r\n";
        
    $email_message .= "Thank You"."\r\n";
        
    $email_message .= "(If you have problems with your custom znz page such as broken referral id links, incorrect email address or name listing, etc. just reply to this message and we will correct the issue as soon as possible)
    "
    ."\r\n";
        
    $email_message .= "ZNZADTEAM.COM";
        
        
    $email_message_admin .= "New affiliate signup details:"."\r\n";
        
    $email_message_admin .= "Affiliate name: $name"."\r\n";
        
    $email_message_admin .= "Affiliate email: $email"."\r\n";
        
    $email_message_admin .= "ZNZ One Referral ID #: $ZNZOne"."\r\n";
        
    $email_message_admin .= "ZNZ Big Cash Referral ID #: $ZNZBigCash"."\r\n";
        
    $email_message_admin .= "Affiliate url: http://www.znzadteam.com/user/$user"."\r\n";
        
    $email_message_admin .= "$comment"."\r\n";
        
        
    // create email headers
        
    $headers 'From: support@ZNZADTEAM.COM';
        
    mail($email_to$email_subject$email_message$headers); 
        
        
    mail($email_admin$email_subject_admin$email_message_admin); 
        }
      echo 
    "We will get to you shortly!";
    }
    ?>

  • #2
    New Coder
    Join Date
    Apr 2013
    Posts
    38
    Thanks
    1
    Thanked 3 Times in 3 Posts
    First of all, just use rename if you intend to move the files.

    Your loop should look like this:
    Code:
    foreach (glob($incoming_file_path . '/*') as $value) {
      rename($value, $processing_file_path . '/' . basename($value))
    }


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •