Jump to content

etsted

Members
  • Posts

    274
  • Joined

  • Last visited

Everything posted by etsted

  1. etsted

    restrict

    this is my php file upload. How can i make sure that the user can only upload images and videos? what type of if statement do i use? <?php include "connect.php"; if(isset($_POST['submit'])) { $name = $_FILES['file']['name']; $temp = $_FILES['file']['tmp_name']; move_uploaded_file($temp, "upload/".$name); $url = "http://localhost:81/upload/$name"; mysql_query("INSERT INTO videos VALUES('','$name','$url')") or die(mysql_error()); } ?> <html> <body> <form action="index.php" method="POST" enctype="multipart/form-data"> <input type="file" name="file" /><br /> <input type="submit" name="submit" /> </form> <a href="videos.php">videos</a> <?php if(isset($_POST['submit'])) { echo "<br />".$name." has been uploaded"; } ?> </body> </html>
  2. etsted

    displaying images

    this is my image code. Is there a way for me to make sure that all of it are displayed on the browser? <html> <body> <form action="index.php" method="POST" enctype="multipart/form-data"> <input type="file" name="file" /><br /> <input type="submit" name="submit" /> </form> <?php include "connect.php"; if(isset($_POST["submit"])) { $loc = "bilder/"; if(($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg")) { $file = explode(".", $_FILES['file']['name']); mysql_query("INSERT INTO bilder VALUES('','".$file[0]."', '".$file[1]."')") or die(mysql_error()); $id = mysql_insert_id(); $newname = $id.$file[1]; $path = "$loc$newname"; move_uploaded_file($_FILES['file']['tmp_name'], $path); echo "du har lastet opp et bilde. klikk her <a href='$path'>klikk</a>"; } else { echo "invalid file"; } } ?> </body> </html>
  3. etsted

    sorting

    i have created a guestbook for my website, but everytime i add a comment it just put the comment below the other. I want it so that the first page only shows maybe 35 comments, then a new page will be created and then 35 comments can be placed there etc. echo "<h1>guestbook</h1>"; echo "<hr />"; $form = " <form action='index.php' method='POST'> <table> <tr> <td>name:</td> <td><input type='text' name='name' /></td> </tr> <tr> <td>message:</td> <td><textarea rows='5' cols='30' name='message'></textarea></td> </tr> <tr> <td></td> <td><input type='submit' name='submit' /></td> </tr> </table> </form> "; include "connect.php"; $getdata = mysql_query("SELECT * FROM guestbook ORDER BY id DESC"); while($row = mysql_fetch_assoc($getdata)) { $id = $row['id']; $name = $row['name']; $message = $row['message']; $date = $row['date']; $message = nl2br($message); echo " <table> <tr> <td><strong>lastet opp av $name. Dato: $date</strong></td> </tr> <tr> <td>$message</td> </tr><br /> </table> "; } echo "<hr />"; $submit = $_POST['submit']; if($submit) { $name = $_POST['name']; $message = $_POST['message']; if($name && $message) { include "connect.php"; $query = mysql_query("SELECT * FROM guestbook WHERE name='$name' && message='$message'"); $numrows = mysql_num_rows($query); if($numrows == 0) { mysql_query("INSERT INTO guestbook VALUES('','$name','$message',CURDATE())"); echo "du har sent en melding $form"; } else { echo "du kan ikke sende den samme meldingen om igjen $form"; } } else { echo "du må fylle ut skjemaet $form"; } } else { echo $form; } ?>
  4. etsted

    image uploader

    does anyone know any videos where i can learn how to both store and upload images to a databse, then retriew them in the browser?
  5. etsted

    video upload

    does anyone know how i can make a php video uploader script?
×
×
  • Create New...