0

How do i create photo upload form with php and retrieve information from database that is not on my server

2
Contributors
1
Reply
4
Views
6 Years
Discussion Span
Last Post by ibakir
1

How do i create photo upload form with php and retrieve information from database that is not on my server

first the php code :

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO table_name (Title, Description, Graphic) VALUES (%s, %s, %s)",
				      
		       GetSQLValueString($_POST['packageTitle'], "text"),
                       GetSQLValueString($_POST['packageDescription'], "text"),
                      // insert the picture name to your data base
                      GetSQLValueString($_FILES['packageGraphic']['name'], "text"));
  

 

  mysql_select_db($database_dalilack, $dalilack);
  $Result1 = mysql_query($insertSQL, $dalilack) or die(mysql_error());

// copy the picture from pc to remote into "uplode" Folder
$target_path = "upload/".$_FILES['packageGraphic']['name'];
move_uploaded_file($_FILES['packageGraphic']['tmp_name'],$target_path);
  $insertGoTo = "marketList.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_dalilack, $dalilack);
$query_product = "SELECT Id, Title, Description, Graphic FROM table_name ";
$product = mysql_query($query_product, $dalilack) or die(mysql_error());
$row_product = mysql_fetch_assoc($product);
$totalRows_product = mysql_num_rows($product);

then after Decotype

<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"  enctype="multipart/form-data">
      <table align="left">
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Title:<br /></td>
          <td><input type="text" name="Title" value="" size="32" /></td>
          </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Description:</td>
          <td><textarea name="Description" cols="32" rows="10"></textarea></td>
          </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Graphic:</td>
          <td><input type="file" name="Graphic" id="upload"  value="" size="32"  /></td>
          </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">&nbsp;</td>
          <td><input type="submit" value="Insert record" /></td>
          </tr>
        </table>
      <input type="hidden" name="MM_insert" value="form1" />
      </form>

Edited by ibakir: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.