Jump to content

PHP file system intergated into my curently form (help please)


Darkwoods

Recommended Posts

hi i have been looking the whole day on how i can do file upload all the tutorials i get are not working for some reason or to complicated to intergate with my form...

 

i will be adding 2 upload fields one for images and the other one for any type of files (large files)

please if you can help... it would be great im so tired of searching on google  ;D

 

here is were i want to have my upload form

 

<?php
include "inc/header.php";


  if(isset($_POST['submit']))
  {//begin of if($submit).
      
  //global variables
      $title_en = $_POST['title_en'];
$title_ar = $_POST['title_ar'];
      $en = $_POST['en'];
      $ar = $_POST['ar'];
      $cat = $_POST['cat'];

              //check if (title) field is empty then print error message.
              if(!$title_en){  //this means If the title is really empty.
                     echo "Error: News title is a required field. Please fill it.";
                     exit(); //exit the script and don't do anything else.
              }// end of ifdtime

         //run the query which adds the data gathered from the form into the database
         $result = mysql_query("INSERT INTO contents (title_en, title_ar, dtime, en, ar, cat)
                       VALUES ('$title_en','$title_ar',NOW(),'$en','$ar','$cat')",$connect);
          //print success message.
          echo "<b>Thank you! data added Successfully!";
          echo "<meta http-equiv=Refresh content=2;url=index.php>";
  }//end of if($submit).


  // If the form has not been submitted, display it!
else
  {//begin of else

      ?>

      <h3>::Add News</h3> 
   <form method="post" action="<?php echo $_SERVER[php_SELF] ?>" enctype="multipart/form-data">  
  <table border="0" cellspacing="4" cellpadding="4">
  <tr>
    <td>Select Category:</td>
    <td colspan="2"><select name="cat"><?php
    
    	$sql = 'SELECT DISTINCT `catname` from `categories`';
$result = @mysql_query($sql,$connect);
while ($row = @mysql_fetch_assoc($result)) {
  echo '<option value="'.$row['id'].'">'.$row['catname'].'</option>';
}      ?>
    
    </td>
  </tr>
    <tr>
    <td>Title:</td>
    <td ><input name="title_en" size="40" maxlength="255"></td>
    <td><input name="title_ar" size="40" maxlength="255"></td>
  </tr>
    <tr>
      <td>Content:</td>
      <td><textarea name="eng"  rows="7" cols="30"></textarea></td>
      <td><textarea name="ar" rows="7" cols="30"></textarea></td>
    </tr>
    <tr>
      <td colspan="3" class="submit"><input type="submit" name="submit" value="Submit"></td>
    </tr>
</table>
      
</form>
     
      <?php
  }//end of else

include "inc/footer.php";
  
?>

 

 

as for the view page i was thinking to have it in this way

 

echo file link only if a file have been uploaded

echo image only if an image have been uploaded

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.