close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Inserting/creating a new folder

Thread began 12/28/2010 8:16 pm by davidp420108 | Last modified 10/04/2011 9:00 am by randyw2394710 | 2401 views | 12 replies |

davidp420108

Inserting/creating a new folder

I would like to have a folder created that holds the clients data when the new client is inserted. The folder name should be the same as the client name.

for example:

insert new record for "Sample Client"
a new folder will be created that is named "SampleClient". Where the space is automatically removed (for better folder management). If it were easier, "Sample_Client" would also be acceptable.

The path would look like SampleClient

Is this something that Data Assist can assist me with?

By the way, i am brand new with PHP and DA so be gentle.

Thanks

Sign in to reply to this post

Ray BorduinWebAssist

In php you can use the mkdir() function... see: function.mkdir.php

You could then use: preg_replace("/[^a-zA-Z0-9s]/", "", $string) to remove the special characters from a string.

Sign in to reply to this post

davidp420108

thanks. This will be my project today

You are a great help Ray!

Sign in to reply to this post

davidp420108

I got the mkdir() down, although it threw me for a loop putting the folder in a different directory off of root until I found $_SERVER['DOCUMENT_ROOT'. thanks.

New question is I want to run...
<?php
$structure = '/Sales/New_Client';
if (!mkdir($_SERVER['DOCUMENT_ROOT'] . $structure, 0, true)) {
die('Failed to create folders...');
}
?>

...once the submit button is clicked. Where New_Client is picked up off the input form. Do I need to insert record first, or can it all be done in one click?

Could you give me a starting point for that? As an easy alternative I was thinking after submit, go to a page that ran the php script. Then go to the page I wanted to be next (i.e results page)

thanks

Sign in to reply to this post

Jason ByrnesWebAssist

you can get the form element value from the post array:
$_POST['New_Client']


so cahnge:
$structure = '/Sales/New_Client';


to;
$structure = '/Sales/'.$_POST['New_Client'].'';

Sign in to reply to this post

davidp420108

Thanks Jason.

Is there a way to make the mkdir() not happen until the insert button is clicked. it is making the folder upon the page loading.

Sign in to reply to this post

Jason ByrnesWebAssist

add an if statement around the makdir function:
if($_SERVER["REQUEST_METHOD"] == "POST") {
<make dir code here>
}

Sign in to reply to this post

davidp420108

Thanks...working great.

I ordered my learn PHP book yesterday. Maybe you won't have to answer these basic questions for me in a week or so...

Thanks again.

David

Sign in to reply to this post

Jason ByrnesWebAssist

Great, glad to hear it is working.

Sign in to reply to this post

Jenny I

Similar Issue

Hi

I have a similar problem to david.

After I complete the steps outlined on davids example how can I dynamically pull up that file directory using a paremeter.

For example say I had 2 seperate forms. Form 1 (front-end) has the input for the clients name

  <input type="text" id="New_Client">Sally Smith  



Form 2 (admin back-end) will have a dynamic select list where the name of the clients will be listed. Based on that selection I would have a next button. This will take admin to another page which will show the file directory in the browser based on the selection. e.g

SallySmith

My question really is what php code would I use to get SallySmith in the browser.

Also in relation to example posted by david where would i insert preg_replace("/[^a-zA-Z0-9s]/", "", $string) to remove spaces.

Your help is much appreciated

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...