Advertisement
Guest User

Untitled

a guest
Jul 7th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.15 KB | None | 0 0
  1.     <?php
  2.     require_once ('konfiguration.php');
  3.      
  4.                
  5.         function sanitize( $input ){
  6.         return mysql_real_escape_string( htmlspecialchars( stripslashes( trim( $input ) ) ) );
  7.         }
  8.        
  9.         if(isset($_POST['title']))
  10.             {
  11.                 $title          = sanitize($_POST['title']);
  12.                 $description    = sanitize($_POST['description']);
  13.                 $applepart      = sanitize($_POST['applepart']);
  14.                 $partnumber     = sanitize($_POST['partnumber']);
  15.                 $productcode    = sanitize($_POST['productcode']);
  16.                 $compatibility  = sanitize($_POST['compatibility']);
  17.                 $images     = sanitize($_POST['images']);
  18.                 $price          = sanitize($_POST['price']);
  19.                
  20.                 $target = "images/";
  21.                 $target = $target . basename( $_FILES['images']['title']);
  22.                
  23.                 $insert = mysql_query("INSERT INTO `adressbuch` (`title`,`description`,`applepart`,`partnumber`,`productcode`,`compatibility`,`images`,`price`) VALUES ('$title','$description','$applepart','$partnumber','$productcode','$compatibility','$images','$price')");
  24.                
  25.                
  26.                
  27.                
  28.                 $pic=($_FILES['images']['title']);
  29.                  
  30.                 if(move_uploaded_file($_FILES['images']['tmp_name'], $target))
  31.                  {
  32.                  echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
  33.                  }
  34.                  
  35.                 if (!$insert)
  36.                 {
  37.                   die('Eintrag konnte nicht gespeichert werden: ' . mysql_error());
  38.             }
  39.         }
  40.     ?>
  41.          
  42.             <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  43.               <span>Neuer Eintrag:</span> <br />
  44.               <span>Title</span><input type="text" name="title" /> <br />
  45.               <span>Description</span><textarea cols="16" rows="5"  name="description"></textarea> <br />
  46.               <span>Apple Part</span><input type="text" name="applepart" /> <br />
  47.               <span>Part Number</span><input type="text" name="partnumber" /> <br />
  48.               <span>Product Code</span><input type="text" name="productcode" /> <br />
  49.               <span>Compatibility</span><input type="text" name="compatibility" /> <br />
  50.               <span>Image</span><input type="file" name="images" /> <br />
  51.               <span>Price</span><input type="text" name="price" /> <br />
  52.               <input type="submit" value="Speichern"/> <br />
  53.             </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement