title: Password Errors with PHP sign up script
body: <p>I am using a PHP Sign-Up  script provided by <em>PHP Form Generator</em>. There was a lot of obsolete code so I had to go in and fix it.</p>
  
  <p>My problem is, the first test user I created worked completely fine, but all other test users I create end up having an unknown Array as the password.</p>
  
  <p>This is the code:</p>
  
  <pre><code>&lt;?php
      include("http://wolffwebdesign.co.cc/php/global.inc.php");
      $errors=0;
      $error="The following errors occured while processing your form input.&lt;ul&gt;";
      $FirstName = mysql_real_escape_string($_POST['FirstName']);
      $MiddleInitial = mysql_real_escape_string($_POST['MiddleInitial']);
      $LastName = mysql_real_escape_string($_POST['LastName']);
      $Company = mysql_real_escape_string($_POST['Company']);
      $Email = mysql_real_escape_string($_POST['Email']);
      $Username = mysql_real_escape_string($_POST['Username']);
      $Password = $_POST['Password'];
      $resultuser = mysql_query("SELECT Username FROM members WHERE Username = '$Username'");
      $resultpass = mysql_query("SELECT Password FROM members WHERE Password = '$Password'");
  
      if($FirstName=="" || $LastName=="" || $Company=="" || $Email=="" || $Username=="" || $Password=="" ){
          $errors=1;
          $error.="&lt;li&gt;You did not enter one or more of the required fields. Please go back and try again.&lt;/li&gt;";
      }
      if(!preg_match('/^[a-z\d_\.\-]+@([a-z\d\-]+)(?:\.(?1))+$/i',$Email)){
          $error.="&lt;li&gt;Invalid email address entered&lt;/li&gt;";
          $errors=1;
      }
      $regex = '~([^A-Z0-9]+)~i'
      if(!preg_match($regex, $Username) || !preg_match($regex, $Password)) {
          $errors.="&lt;li&gt;Invalid Username or Password entered&lt;/li&gt;";
          $errors=1;
      }
  
      if($errors==1) {
          echo $error;
      }
      if(mysql_num_rows($resultuser) == 1){
           die("&lt;li&gt;That Username exists already&lt;/li&gt;");
      }
      if(mysql_num_rows($resultpass) == 1){
         die("&lt;li&gt;That password exists already&lt;/li&gt;");
      }
      else{
          if($remember == 1)
              {$expire=time()+50400;
              setcookie("extendedloginwwd", $Username, $expire);
          }
          elseif($remember == 0)
              {$expire=time()+50400;
              setcookie("loginwwd", $Username, $expire);
          }
          mkdir("home/wolffweb/www/$Username", 0755);
          $where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
          mail( "wolffswebdesign@gmail.com", "New User Submission", "Name: $LastName, $FirstName, $MiddleInitial\nCompany: $Company\nEmail: $Email\nUsername: $Username\nPassword: $password\nFolder: $dirname\nErrors?: $error\n", "From: Sign Up &lt;newuser@wolffwebdesign.x10.mx&gt;" );
          $link = mysql_connect("localhost","wolffweb_admin","jl10101");
          mysql_select_db("wolffweb_users",$link);
          $query="insert into members (First_Name,Middle_Initial,Last_Name,Company,Email,Username,Password) values ('".$FirstName."','".$MiddleInitial."','".$LastName."','".$Company."','".$Email."','".$Username."','".$Password."')";
          mysql_query($query);
          $make=fopen("admin/data.dat","a");
          $to_put="";
          $to_put .= $FirstName."|".$MiddleInitial."|".$LastName."|".$Company."|".$Email."|".$Username."|".$Password."
          ";
          fwrite($make,$to_put);
      }
      ?&gt;
  </code></pre>
  
  <p>This is the shown content:</p>
  
  <pre><code>&lt;!-- This is the content of the Thank you page, be careful while changing it --&gt;
  
      &lt;h2&gt;Thank you!&lt;/h2&gt;
  
      &lt;table width=50%&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  First Name: 
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;?php echo $FirstName; ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  Middle Initial: 
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;?php echo $MiddleInitial; ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  Last Name: 
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;?php echo $LastName; ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  Company: 
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;?php echo $Company; ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  Email: 
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;?php echo $Email; ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  Username: 
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;?php echo $Username; ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  Password: 
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;?php echo $Password; ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;!-- Do not change anything below this line --&gt;
  
  &lt;?php
  {}
  ?&gt;
  </code></pre>
  
  <p>If, for example, I made my password <em>hello52</em> where <code>&lt;?php echo $Password; ?&gt;</code> and also in the MYSQL Database the password ends up being the word <em>Array</em>, which when I plug <em>Array</em> in to the Log In form I get an incorrect password error. My assumption is that the password ends up being some sort of random array. Is there any way to fix this?</p>
  
  <p>EDITS:</p>
  
  <p>The following is the form code:</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" action="http://wolffwebdesign.co.cc/php/sign-up.php" method="post"&gt;
      &lt;table border="1" cellspacing="1" style="border-collapse: collapse" border="#000066" width="95%" cellpadding="5"&gt;
          &lt;tr&gt;
              &lt;td colspan="3" bgcolor="#B5CBEF" height="17" width="100%" border="#FFFFFF" background="http://wolffwebdesign.co.cc/media/tile_back.gif"&gt;
                  &lt;p align="left" class="c1"&gt;&lt;img border="0" src="nav_m.gif" width="8" height="8" alt="triangle"&gt;&lt;strong&gt;&amp;nbsp;Sign Up&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td colspan="3" bgcolor="#B5CBEF" height="16" width="100%" border="#FFFFFF" background="http://wolffwebdesign.co.cc/media/tile_sub.gif"&gt;
                  &amp;nbsp;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td colspan="3" bgcolor="#D6DFEF" height="16" width="100%" border="#FFFFFF"&gt;
                  &lt;p class="c2"&gt;* - Required&lt;/p&gt;
                  &lt;p class="c2"&gt;+ - Alpha-Neumeric only(A-Z, a-z, 0-9)
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td height="30" width="55" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;img border="o" src="http://wolffwebdesign.co.cc/media/bc_new.gif" width="28" height="28" alt="triangle in a blue circle"
              &lt;/td&gt;
              &lt;td height="30" width="189" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c3"&gt;First Name&lt;/p&gt;
              &lt;/td&gt;
              &lt;td height="30" width="294" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c5"&gt;&lt;input type="text" name="FirstName" size="25"&gt;*&lt;/p&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td height="30" width="55" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;img border="o" src="http://wolffwebdesign.co.cc/media/bc_new.gif" width="28" height="28" alt="triangle in a blue circle"
              &lt;/td&gt;
              &lt;td height="30" width="189" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c3"&gt;Middle Initial&lt;/p&gt;
              &lt;/td&gt;
              &lt;td height="30" width="294" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c5"&gt;&lt;input type="text" name="MiddleInitial" size="1"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td height="30" width="55" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;img border="o" src="http://wolffwebdesign.co.cc/media/bc_new.gif" width="28" height="28" alt="triangle in a blue circle"
              &lt;/td&gt;
              &lt;td height="30" width="189" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c3"&gt;Last Name&lt;/p&gt;
              &lt;/td&gt;
              &lt;td height="30" width="294" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c5"&gt;&lt;input type="text" name="LastName" size="25"&gt;*&lt;/p&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td height="30" width="55" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;img border="o" src="http://wolffwebdesign.co.cc/media/bc_new.gif" width="28" height="28" alt="triangle in a blue circle"
                                  &lt;/td&gt;
              &lt;td height="30" width="189" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c3"&gt;Company&lt;/p&gt;
              &lt;/td&gt;
              &lt;td height="30" width="294" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c5"&gt;&lt;input type="text" name="Company" size="25"&gt;*&lt;/p&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td height="30" width="55" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;img border="o" src="http://wolffwebdesign.co.cc/media/bc_new.gif" width="28" height="28" alt="triangle in a blue circle"
              &lt;/td&gt;
              &lt;td height="30" width="189" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c3"&gt;Email&lt;/p&gt;
              &lt;/td&gt;
              &lt;td height="30" width="294" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c5"&gt;&lt;input type="text" name="Email" size="25"&gt;*&lt;/p&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td height="30" width="55" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;img border="o" src="http://wolffwebdesign.co.cc/media/bc_new.gif" width="28" height="28" alt="triangle in a blue circle"
              &lt;/td&gt;
              &lt;td height="30" width="189" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c3"&gt;Username&lt;/p&gt;
              &lt;/td&gt;
              &lt;td height="30" width="294" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c5"&gt; input type="text" name="Username" size="20"&gt;*+&lt;/p&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td height="30" width="55" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;img border="o" src="http://wolffwebdesign.co.cc/media/bc_new.gif" width="28" height="28" alt="triangle in a blue circle"
              &lt;/td&gt;
              &lt;td height="30" width="189" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c3"&gt;Password&lt;/p&gt;
              &lt;/td&gt;
              &lt;td height="30" width="294" bgcolor="#EFF3F7" border="#FFFFFF"&gt;
                  &lt;p class="c5"&gt; input type="password" name="Password" size="10"&gt;*+&lt;/p&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td colspan="3" bgcolor="#B5CBEF" height="25" width="538" background="tile_sub.gif"&gt;
                  &lt;p align="center"&gt;&lt;p class="c3"&gt;&lt;input type="submit" value="Submit Form"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;input type="reset" value="Reset Form"&gt;&lt;/font&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Also I am using the mkdir() function because I want each user to have their own directory which contains a service page, the directory is not being created, is there any way to fix this?<br>
  Thanks<br>
  --James </p>