Jump to content

remove spaces and create folder


jesushax

Recommended Posts

hi i have a add company form

 

what i want to do is

 

take the below

 

$strCompanyName = mysql_real_escape_string($_POST["txtCompanyName"]);

 

remove any spaces in the company name

 

then create a sub-folder with the new company name in the below

 

/clients/

 

can anyone show or point me in the right direction for these please?

 

Thanks

Link to comment
Share on other sites

right heres my code

 

i got the strign replace

 

but the folder is not getting created in my clients folder

 

<?php
switch(@$_GET["mode"])
{
    case "add":

include($_SERVER['DOCUMENT_ROOT'] . '/includes/header-logged.php');
include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php');
include($_SERVER['DOCUMENT_ROOT'] . '/includes/admin_access.inc');	

$strUserName = mysql_real_escape_string($_POST["txtUserName"]);
    $strFirstName = mysql_real_escape_string($_POST["txtFirstName"]);
    $strLastName = mysql_real_escape_string($_POST["txtLastName"]);		
    $strTel = mysql_real_escape_string($_POST["txtTel"]);
    $strHomePage = mysql_real_escape_string($_POST["txtHomePage"]);		
    $strCompanyName = mysql_real_escape_string($_POST["txtCompanyName"]);
$strFolderPath = str_replace(' ','',$strCompanyName); 
    $strUserPass = md5($_POST["txtUserPass"]);
    $strEmail = mysql_real_escape_string($_POST["txtEmail"]);
    $strDate = date("d/m/y");

  
      if(!strlen($strUserName)) { echo "<p style=\"color:#FF0000;\">Error: Username Was Left Blank</p>";   }
  
  elseif(!strlen($strEmail)){ echo "<p style=\"color:#FF0000;\">Error: Email Was Left Blank</p>";  }
  
  else{	
  		$result = mysql_query("SELECT UserName FROM tblUsers WHERE UserName='". $strUserName ."' ") or die(mysql_error());
	  	if (mysql_num_rows($result)  > 0)
	  	{ echo "<p style=\"color:#FF0000;\">Error: Username Taken</p>"; }

	   	else{
mysql_query("INSERT INTO tblUsers (UserName, UserAdmin, UserPassword, UserEmail, UserCompanyName, UserCompanyFolder, UserFirstName, UserLastName, UserTel, UserHomePage, UserDateAdded)
Values(  '".$strUserName."','0' ,'".$strUserPass."', '".$strEmail."', '".$strCompanyName."', '".$strFolderPath."', '".$strFirstName."', '".$strLastName."', '".$strTel."', '".$strHomePage."', '".$strDate."')") or die(mysql_error());

		mkdir("/clients/".$strFolderPath."");

          header('Location: ?mode=done');
          exit; }
      	}
  break;
  
    case "done":
      include($_SERVER['DOCUMENT_ROOT'] . '/includes/header-logged.php');
  include($_SERVER['DOCUMENT_ROOT'] . '/includes/admin_access.inc');
      echo "</p>Account has been created.</p>";
      break;
  
  break;
    default:
      include($_SERVER['DOCUMENT_ROOT'] . '/includes/header-logged.php');
  include($_SERVER['DOCUMENT_ROOT'] . '/includes/admin_access.inc');
}
include($_SERVER['DOCUMENT_ROOT'] . '/includes/nav/companies.inc');
?>
<b>Add an account</b>
<form id="Profile" method="post" action="?mode=add">
  <table width="100%" border="0" style="padding:0px; margin:0px;">
    <tr>
      <td>Username: </td>
      <td><input type="text" name="txtUserName" size="50" /></td>
    </tr>
    <tr>
      <td>Password:</td>
      <td><input type="password" name="txtUserPass" size="25" /></td>
    </tr>
    <tr>
      <td>Confirm Password:</td>
      <td><input type="password" name="txtUserPass2" size="25" /></td>
    </tr>
    <tr>
      <td>Email Address:</td>
      <td><input type="text" name="txtEmail" size="50" /></td>
    </tr>
    <tr>
      <td>Company Name</td>
      <td><input type="text" name="txtCompanyName"	size="50" /></td>
    </tr>
    <tr>
     <td>First Name:</td>
      <td><table width="100%" border="0" style="padding:0px; margin-left:-3px;">
        <tr>
          <td><input type="text" name="txtFirstName" size="20" /></td>
          <td> 
Last Name:</td>
          <td><input type="text" name="txtLastName" size="20" /></td>
        </tr>
      </table></td>
    </tr>
    <tr>
      <td>Website Address</td>
      <td><input type="text" name="txtHomePage" size="50" /></td>
    </tr>
    <tr>
      <td>Tel: </td>
      <td><input type="text" name="txtTel" size="15" /></td>
    </tr>
    <tr>
      <td colspan="2" style="text-align:center;"><input type="submit" name="Submit" value="Add User" alt="Enter" />
 
<input type="Reset" name="Reset" value="Cancel" alt="Cancel" /></td>
    </tr>
  </table>
</form>
* a valid working email is required as your login and activation information will be sent there, thankyou.
<?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'); ?>

 

no error messages either

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.