The form…
[php]
Step 1. Choose a picture:
Image maximum size 5 MB jpeg, gif, or png
or enter image url:
Step 2. Enter a caption for the image:
Step 3. Judg whatever/whoever is in that picture:
(Maximum characters: 350)
You have characters left.
Have a link?
<input type="hidden" name="url" value='<?php echo "Date:".date('Y-m-d H:i:s')."<br />Ip:".$_SERVER['REMOTE_ADDR'].""?>'/>
<label for="submit"><span class="steps">Step 4.</span> Submit it:</label>
<input type="submit" id="mybut" value=" Judg It! " name="Submit"/>
[/php]
the insertion into db…
[php]<?php
require ‘db.php’;
error_reporting(0);
$limitedtextarea = mysql_real_escape_string(urldecode($_POST[‘limitedtextarea’])); //The actual judgment
$url = mysql_real_escape_string($_POST[‘url’]); //URL (Actually now set to get IP Address of user uploading)
$figcaption = mysql_real_escape_string(urldecode($_POST[‘figcaption’])); //Caption for the image
$imageURL = mysql_real_escape_string($_POST[‘imageURL’]); //URL for and image
$link = mysql_real_escape_string($_POST[‘link’]);
if($imageURL==null && $_FILES[‘file’][‘name’]==null)
{
echo"";
}
else{
$change= “http://www.judgd.com”;
$abc="";
define (“MAX_SIZE”,“3000”);
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return “”; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
$errors=0;
if($_SERVER[“REQUEST_METHOD”] == “POST”)
{
$image =$_FILES[“file”][“name”];
$uploadedfile = $_FILES[‘file’][‘tmp_name’];
$fileSize = $_FILES[‘file’][‘size’];
$fileType = $_FILES[‘file’][‘type’];
if ($image)
{
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != “jpg”) && ($extension != “jpeg”) && ($extension != “png”) && ($extension != “gif”))
{
$change='<div class="msgdiv">Unknown Image extension </div> ';
$errors=1;
}
else
{
$size=filesize($_FILES[‘file’][‘tmp_name’]);
if ($size > MAX_SIZE*5000)
{
$change='
You have exceeded the size limit!
';
die;
$errors=1;
}
if($extension==“jpg” || $extension==“jpeg” || $extension==“pjpeg”)
{
$uploadedfile = $_FILES[‘file’][‘tmp_name’];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension==“png”)
{
$uploadedfile = $_FILES[‘file’][‘tmp_name’];
$src = imagecreatefrompng($uploadedfile);
}
else
{
$src = imagecreatefromgif($uploadedfile);
}
echo $scr;
$percent = 0.5;
list($width,$height)=getimagesize($uploadedfile);
$newwidth=$width;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
$newwidth1=$width*$percent;
$newheight1=($height/$width)*$newwidth1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1);
$newwidth2=$width*$percent*$percent;
$newheight2=($height/$width)*$newwidth2;
$tmp2=imagecreatetruecolor($newwidth2,$newheight2);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);
imagecopyresampled($tmp2,$src,0,0,0,0,$newwidth2,$newheight2,$width,$height);
$filePath = “images/”;
$filePathSmall = “images/small/”;
$filePathThumb = “images/thumbnail/”;
$filename = $_FILES[‘file’][‘name’];
$filenamesmall = $newheight1.“x”.$newheight1."_".$_FILES[‘file’][‘name’];
$filenamethumb = $newheight2.“x”.$newheight2."_".$_FILES[‘file’][‘name’];
imagejpeg($tmp,$filePath.$filename,100);
imagejpeg($tmp1,$filePathSmall.$filenamesmall,100);
imagejpeg($tmp2,$filePathThumb.$filenamethumb,100);
imagedestroy($src);
imagedestroy($tmp);
imagedestroy($tmp1);
imagedestroy($tmp2);
}}
}
$fileName = $filename;
if($fileName==null){
$fileName=$imageURL;
}
//If no errors registred, print the success message
if(isset($_POST[‘Submit’]) && !$errors)
{
// mysql_query(“update {$prefix}users set img=’$big’,img_small=’$small’ where user_id=’$user’”);
$query = “INSERT INTO judgment (limitedtextarea, name, namesmall, namethumb, size, type, path, url, figcaption, link )
VALUES (’$limitedtextarea’,’$fileName’,’$filenamesmall’,’$filenamethumb’, ‘$fileSize’, ‘$fileType’, ‘$filePath’, ‘$url’, ‘$figcaption’,’$link’)”;
$result = mysql_query($query) or die('Error, query failed : ’ . mysql_error());
if(!$result){
print ‘’;
}
else {
echo “
Post Successful!
”;
}
}
}[/php]
calling it from db…
[php]echo ("");
$ipadd = $_SERVER[‘REMOTE_ADDR’];
if($row[‘path’]==null) // IF PATH IS NULL; THEN IMAGE IS URL; DO THIS…
{
echo ("
<table itemscope itemtype='http://schema.org/Review' class='showing'>
<tr>
<td rowspan='1' colspan='1'>
<figure>
<a itemprop='contentUrl' href='".$row['name']."' rel='lightbox' title=\"".$row['figcaption']." - ".$row['limitedtextarea']."\">
<img class='figImg' itemprop='thumbnailUrl' src='". $row['name']."' alt='".$row['name']."' title='".$row['name']."'/></a></figure>
</td>
</tr>
<tr>
<td class='figcap'><a href='judgment_search.php?figcaption=".$row['figcaption']."' title='".$row['figcaption']."'>".$row['figcaption']."</td>
</tr>
<tr>
<td rowspan='1' colspan='1'><span itemprop='comment'>".$row['limitedtextarea']."</span></td>
</tr>
<tr>");
if ($row['link']==!null){
echo "<td><a href='".$row['link']."' title='".$row['link']."' target='_blank'>Link</a></td>";
}
echo ("<td></td>
</tr>
<tr>
<td>
<div class='fb-like' data-href=\"http://www.judgd.com/judgment_search?figcaption=".$row['figcaption']."\" data-send='true' data-layout='button_count' data-width='250' data-show-faces='false'></div>
<a href='http://pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.judgd.com%2F&media=".$row['name']."&description=".urlencode($row['limitedtextarea'])."' class='pin-it-button' count-layout='horizontal'><img border='0' src='//assets.pinterest.com/images/PinExt.png' title='Pin It' /></a>
</td>
</tr>
</table>
<!-- <![endif]-->
");
}
[/php]
when “don’t” or “it’s” or anyting with an apostrophe it triples it when inserting it into the db