How to pass a variable into a file path in PHP -
i trying pass user entered company path determine content displayed. have company submitting page form on , path content display. include mkdir if new company name.
$path = '(uploadedfiles/($_post['companyname']))'; $dirs = scandir($path); not sure why getting undefined index error. here portion asking name on page named admin.php
print '<form action="admin.php" method="post">'.php_eol; print' <h4> enter name of company new uploads belong to.</h4>'; print' <label class="control-label" `for="companyname">companyname</label>';` print' <input type="text" name="" id="companyname" placeholder="enter comapny name ">'; print' <button type="submit" class="btn">enter</button>'; print' </div>';
the best way (zend code style guide) concat this:
$path = 'uploadedfiles/' . $_post['companyname']; // works double- // , single-quotes but warned: accepting user input, non-validated system can result in hacking attempts.
another way this:
$path = "uploadedfiles/{$_post['companyname']}"; // double-quotes
Comments
Post a Comment