Hi,
Thanks all for your responses! I really appreciate the help.
I am now able to write a dynamic folder/file to my host's server (using below script)...
...But, now I am having big probs with being able to delete the same folder/files from server!
I think it is because PHP runs as the user "nobody", which means that I need to login as "nobody" to delete the files, but unfortunately, I am not sure what software/how to log-in as "nobody" to do that... any suggestions (me = mac user)?
Or, how can I write the below code to make files/folders with proper perms? My host, webhostfreaks, only allows a max chmod of 666

.
Also, anyone have suggestions when it comes to error-checking the two form fields? I tried "isset" and "empty" with no luck...
Code: Select all
<?php
error_reporting(E_ALL ^ E_NOTICE); // Turn off error "Notice" reporting.
//error_reporting(0); // Turn off error reporting.
if ($_GET['action'] == 'create_quote') { // Generate quote/bid:
$en_form_num = number_format($quote); // Add commas to the quote number.
// HTML to be written:
$html='<head><title>Quote for '.$company.'</title></head>';
$html.='This is a $'.$en_form_num.' quote for '.$company.'.';
$file_name = strtolower($company); // Make company name lower-case for making file.
$file_name = htmlspecialchars(stripslashes($file_name)); // Convert to special chars and strip slashes.
$urls = array(' ', '.', '?', '=', '+', ':', '%', '$', ','); // Create array and pop with items to be stripped from var.
$file_name = str_replace($urls,"_",$file_name); // Now remove above array items from company name.
$qfname = $file_name.'_quote';
// Make directory and open file:
if(!is_dir('./'.$file_name)) { mkdir('./'.$file_name); }
$fp = fopen('./'.$file_name.'/'.$qfname.'.html','w'); // Open for writing only; If the file does not exist, attempt to create it.
fwrite($fp,$html);
fclose($fp);
echo "your file has been created, <a href='./$file_name/$qfname.html'>click here</a> to scope it!";
exit();
}
echo "<form action='".$_SERVER['PHP_SELF']."?action=create_quote' method='post' name='create_quote_now'>"."\n";
print <<< PRINT_PAGE
Company: <input name="company" type="text" size="15" maxlength="40">
Quote: $<input name="quote" type="text" size="15" maxlength="40">
<input name="submit" type="submit" value="Submit">
</form>
PRINT_PAGE;
?>
Also, how could I avoid using exit() while still hiding other parts of the script? Meaning, on the above script, when the form gets submitted, it goes to a "congrats page"... without the exit(), I would still see the form... any tips/suggestions? I am guessing the best thing to do is to break up my script into multiple PHP pages.
Any (more) help would rock!
Thanks! Cheers!

M