Jump to content

Updating a single file


franknu

Recommended Posts

Ok, i want to update a single file some of the info i request is being display except for the picture and the second one is that it is not updating into the database i guess. i have to problem in one

 

here is my code:

 

<?php

if ( isset($_SESSION['User_Name']) && isset ($_SESSION['Password']) ) 
{
$query = "SELECT * FROM business_info where User_Name='".$_SESSION['User_Name']."' AND Password='".$_SESSION['Password']."'" ;
$result=mysql_query($query);

}

  if ($result = mysql_query($query)) 
{
    if (mysql_num_rows($result))
{
      $row = mysql_fetch_assoc($result);

      $BusinessName= $row['BusinessName'];
      $Keyword = $row['Keyword'];
      $Picture1 =  $row['Picture1'];
      $Headline = $row['Headline'];
      $Slogan =$row['Slogan'];
      $Slogan2 = $row['Slogan2'];
      $Description1 =$row['Description1'];
      $Description2 = $row['Description2'];
      $Description3= $row['Description3'];
      $Contact2 =  $row['Contact2'];
      $Picture2 = $row['Picture2'];
      $Picture3 = $row['Picture3'];
      $Categories=$row['Categories'];
      $Business_Address= $row['Business_Address'];
      $make=$row['make'];
      $type=$row['type'];
      $Tel= $row['Tel'];
      $Website=$row['Website'];
    } 
  } 
else 
{
    echo "Query failed<br />$query<br />". mysql_error();
exit;
  }

?>



<table width="622" border="1" bgcolor="#CCCCCC">
  <tr>
    <td width="612" bgcolor="#FFFFFF">

<?
echo"$BusinessName";
$_SESSION['User_Name'];
$_SESSION['Password'];
?>

<pre>_SESSION:<?php print_r($_SESSION); ?></pre> 

<?
$image = preg_replace('#^.*/public_html#', '', $row['Picture3']);
            echo '<img src="' . $image . '" width="235" height="250">'; 
?>

<?php
if (isset($_POST['submit']))

IF ($_FILES['Picture2']) {
$moved1 = false;
  IF (is_uploaded_file($_FILES['Picture2']['tmp_name'])) {
   $fullpath2 = UPLOADDIR . $_FILES['Picture2']['name'];
    
    IF (move_uploaded_file($_FILES['Picture2']['tmp_name'],$fullpath2)) {
      $moved2 = true;
      echo "picture $fullpath2 uploaded";
}
  }
}


{
$query="UPDATE  business_info  SET 
              `Picture3` =  '".$_POST[Picture3]."' WHERE  Password='".$_SESSION['Password']."'";



$result = mysql_query($query) or die ("Problem with the query: <pre>$query</pre><br>" . mysql_error());
echo"$query";
}
?>


<? echo'<form action="'. $_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">'; ?>

<table width="605" border="1">
      <tr>
        <td width="595"><? echo"<input type='file' name='file'>"; ?></td>
      </tr>
      <tr>
        <td> </td>
      </tr>
    </table>      
      <table width="594" border="0">
        <tr>
          <td width="445"> <? echo"  <input type='reset' value='Reset fields' />"; ?>
            <div align="right"></div>
          <div align="right"></div></td>
          <td width="139"> 
  
  <? echo" <input type='submit'  value='Update my database' name='submit' />"; ?>
         </td>
        </tr>
      </table>

 

MOD EDIT: use code tags, not php tags

<?php
   // your code
?>

 

Link to comment
https://forums.phpfreaks.com/topic/53615-updating-a-single-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.