Jump to content

Mikkel

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Mikkel's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes, I'm looking for a way of putting file (image) upload into a form, along with text upload. It's really the PHP upload (to the DB) script itself that I'm having trouble with - the stuff that would go into save_form.php. Thanks alot though. :)
  2. I'm a PHP/MySql rookie, and these last few weeks I've been working on a problem. I need to make a site that is fully dynamic for the end user. I'm able to make PHP forms to submit text to the database, but is there also a way to incorporate image upload in such a form? I've experimented with BLOB storage, and have managed to store images in the database via a PHP script, but so far haven't been able to retrieve them as jpg's in the browser. I've tried so many tutorials, but nothing has worked. My ultimate wish is to have 1 single form for the user to enter a Headline, Text, and Name, and optionally, browse their HD for a image to be uploaded to the DB. This image will then be posted on the front page along with the other rows (text). Is this even possible with PHP? Would be immensly grateful for ANY help.  :) This is the form located in news_form.php. [code] <form id="form1" name="form1" method="post" action="save_form.php"> <input name="headline" type="text" style='width: 98%' maxlength="50"/> <textarea name="text" style="width: 98%; height: 100px"></textarea> <input name="name" type="text" style='width: 40%' maxlength="50"/> <input type="reset" name="Reset" value="Empty form" /> <input type="submit" name="Submit" value="Publish" /> </form>[/code] This is the PHP currently in save_form.php. Everything works brilliantly so far, but what if I wanted to be able to upload an JPG file in the same form, along with the text? [code]<?PHP        $headline = addslashes(htmlentities($_POST['headline']));   $text = addslashes(htmlentities($_POST['text']));      $name = addslashes(htmlentities($_POST['name']));   if($headline!="" and $text!="" and $name!=""){     $dbconnection = mysql_connect('localhost','*****','****');     mysql_select_db('******',$dbconnection); $created_time = date("Y.m.d H.i.s");           $sql = "Insert into news(headline,text,name,created_time) Values('$headline','$text','$name','$created_time')";     $dbResults = mysql_query($sql);           if($dbResults) {         echo("<b>Congratulations, your news have been posted.</b> <br/>");         echo("<p><a href='../../index.php'>Click here</a> to read your news, or <a href='../../kontrollpanel.php'>go back to the control panel.</a></p>");     }else {         echo("<b>Oops, something went wrong! Contact webmaster.</b>");     }       }else{     echo("You need to fill out the whole form!"); } ?> [/code]
×
×
  • 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.