<?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); ?>
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?