title: How to store file name in database, with other info while uploading image to server using PHP?
body: <p>Hi I have read many forums and websites that tell you how to upload an image to a server and I have managed to get this working, I can upload a file to a my server but storing the file name does work on the following example I found and I also need to create a form that allows more data to be entered to the database. I am stuck with this as a have done much PHP before. I have come to the end of trying different websites tutorials with no much success could anyone please help me! I need it done for a project I'm doing. </p>
  
  <p>I am basically trying to make a CMS that allows users to upload a photo of a band member and have information stored about them so that it can be displayed on a webpage for the public to view. </p>
  
  <hr>
  
  <p>My Table looks like this: </p>
  
  <pre><code>Field              Type             Null    Default     
  id                 int(10)          No                   
  nameMember         varchar(25)      No                   
  bandMember         text             No                   
  photo              varchar(30)      No                   
  aboutMember        text             No                   
  otherBands         text             No      
  </code></pre>
  
  <p>The form I want will look like this:</p>
  
  <pre><code>   &lt;h1&gt;Adding a new Band Member or Affiliate&lt;/h1&gt;
        &lt;form method="post" action="addMember.php" enctype="multipart/form-data"&gt;
         &lt;p&gt;
                Please Enter the Band Members Name.
              &lt;/p&gt;
              &lt;p&gt;
                Band Member or Affiliates Name:
              &lt;/p&gt;
              &lt;input type="text" name="nameMember"/&gt;
              &lt;p&gt;
                Please Enter the Band Members Position. Example:Drums.
              &lt;/p&gt;
              &lt;p&gt;
                Member's Position:
              &lt;/p&gt;
              &lt;input type="text" name="bandMember"/&gt;
              &lt;p&gt;
                Please Upload a Photo in gif or jpeg format. The file name should be named after the Members name. If the same file name is uploaded twice it will be overwritten!
              &lt;/p&gt;
              &lt;p&gt;
                Photo:
              &lt;/p&gt;
              &lt;input type="file" name="filep" size=35 /&gt;
              &lt;p&gt;
                Please Enter any other information about the band member here.
              &lt;/p&gt;
              &lt;p&gt;
                Other Member Information:
              &lt;/p&gt;
  &lt;textarea rows="10" cols="35" name="aboutMember"&gt;
  &lt;/textarea&gt;
              &lt;p&gt;
                Please Enter any other Bands the Member has been in.
              &lt;/p&gt;
              &lt;p&gt;
                Other Bands:
              &lt;/p&gt;
              &lt;input type="text" name="otherBands" size=30 /&gt;
              &lt;br/&gt;
              &lt;br/&gt;
              &lt;input TYPE="submit" title="Add data to the Database" value="Add Member"/&gt;
            &lt;/form&gt;
  </code></pre>
  
  <p>The Example that uploads an Image to the server and only, that is this: </p>
  
  <pre><code>&lt;?
  
  if ($_POST["action"] == "Load")
  {
  $folder = "images/";
  
  move_uploaded_file($_FILES["filep"]["tmp_name"] , "$folder".$_FILES["filep"]["name"]);
  
  echo "
  &lt;p align=center&gt;File ".$_FILES["filep"]["name"]."loaded...";
  
  $result = mysql_connect("localhost", "******", "*****") or die ("Could not save image name
  
  Error: " . mysql_error());
  
  mysql_select_db("project") or die("Could not select database");
  mysql_query("INSERT into dbProfiles (photo) VALUES('".$_FILES['filep']['name']."')");
  if($result) { echo "Image name saved into database
  
  "; }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>And the Examples form I have to use is this: </p>
  
  <pre><code>&lt;form action=addMember.php method=post enctype="multipart/form-data"&gt;
  &lt;table border="0" cellspacing="0" align=center cellpadding="3" bordercolor="#cccccc"&gt;
  &lt;tr&gt;
  &lt;td&gt;File:&lt;/td&gt;
  &lt;td&gt;&lt;input type="file" name="filep" size=45&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td colspan=2&gt;&lt;p align=center&gt;
  &lt;input type=submit name=action value="Load"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>PS: Images file is open for writing to. </p>