1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

easy ? for you php heads pass a variable create a directory

Discussion in 'PHP' started by kool-aid, Oct 8, 2007.

  1. #1
    <?php

    I need to pass my variable clients name into a command that creates a directory. How would i do this? I suck at php.

    $_POST["repsName"] . $_POST["clientsName"]. $_POST["clientsPhone"]. $_POST["clientsUrl"]. $_POST["shortDescroption"]. $_POST["longDescription"];

    if(is_dir("./files")) mkdir("./files/newDir", 0755);

    $mode = file_exists('user_input.txt')?'a':'w'; // append if file exists otherwise create it
    $fp = fopen('user_input.txt',$mode); // open file
    fwrite($fp,print_r($_POST,true)."\r\n"); // dump the contents of the $_POST array to the file
    fclose($fp);
    ?>
     
    kool-aid, Oct 8, 2007 IP
  2. sea otter

    sea otter Peon

    Messages:
    250
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Couple of questions.

    1. What are you trying to do here:

    
    $_POST["repsName"] . $_POST["clientsName"]. $_POST["clientsPhone"]. $_POST["clientsUrl"]. $_POST["shortDescroption"]. $_POST["longDescription"];
    
    Code (markup):
    2. What is "newDir" supposed to be here? A name that came from somewhere or resides in a variable? Where does it come from:

    
    if(is_dir("./files")) mkdir("./files/newDir", 0755); 
    
    Code (markup):
    3. Do you just want every entry in the $_POST array dumped to the file, or only those named in (1) above, and in the order in (1) above? Any newlines separating the fields, or just dump them running one into the next?


    e.g., are you trying to do something like this:

    
    Mr. Rep
    Mr. Client
    555-555-5555
    www.client-url.com
    this is a short description.
    this is a longer description, but note that it still doesn't have a linefeed.
    Mr. Rep number 2
    Mr. Client number 2
    555-555-5555
    www.second-client-url.com
    this is a short description for the second client.
    this is a longer description for the second client, but note that it still doesn't have a linefeed.
    
    Code (markup):
    If you put each field on a line but you also allow appending to the file as you indicate in your code, you'll run into trouble if there are any newline characters in the short or long description.

    Is that going to be a problem?
     
    sea otter, Oct 8, 2007 IP