更新图片上传代码:
<div id="uploadform">
<form action="laddaupp.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="500000" />
<label for="file"><strong>Filename:</strong></label>
<input type="file" name="file" id="file" />
<input type="text" name="uppladdare" placeholder="Uploader:" title="What's your name?"/>
<input type="text" name="titel" placeholder="Title" title="Give a title to your piece of work"/>
<input type="text" name="history" placeholder="History" title="Tell us the story behind your image. Where is it taken, etc."/>
<input type="submit" name="submit" value="Upload" />
</form>
//Send data to database
if(isset($_POST['submit']))
{
$dbcon = mysqli_connect("localhost","user1","test1","tutorial");
$stored_file = $_FILES["file"]["name"];
$file = "";
$query="INSERT INTO mountains (filname, uppladdare, titel, History)
VALUES ('$stored_file','$_POST[uppladdare]','$_POST[titel]','$_POST[history]')";
if(!mysqli_query($dbcon ,$query));
}
评分代码:
<form name="rating" id="rating">
<div id="rating-area" class="shadow">
<img src="stjärna.png" id="thumb1" data-value="1" />
<img src="stjärna.png" id="thumb2" data-value="2" />
<img src="stjärna.png" id="thumb3" data-value="3" />
<img src="stjärna.png" id="thumb4" data-value="4" />
<img src="stjärna.png" id="thumb5" data-value="5" />
</div>
</form>
<!--Skickar information till textfilen när man klickar på en stjärna-->
<script>
jQuery('div#rating-area img').click(function(e){
var val = jQuery(this).data('value') ;
console.log(val) ;
jQuery.post('post.php',{ rating : val },function(data,status){
console.log('data:'+data+'/status'+status) ;
}) ;
}) ;
</script>