Salve a tutti, ho un problema. Mi hanno costruito un'interfaccia gestionale dove inserire immagine, titolo, testo e altre immagini.
Quando digito un testo nel box testo se ci sono apostrofi il gestionale non invia i dati al DB.
Ipotizzo che la stringa addslashes() debba essere inserita nel form di invio, ma non so ne dove e ne come.
Mi aiutereste?! GRAZIE
Vi invio il codice:
<?
include_once ('conn.php');
function resize2 ($picture,$max) {
$src_img=ImagecreateFromJpeg($picture);
$oh = imagesy($src_img); # original height
$ow = imagesx($src_img); # original width
$new_h = $oh;
$new_w = $ow;
if($oh > $max || $ow > $max){
$r = $oh/$ow;
$new_h = ($oh > $ow) ? $max : $max*$r;
$new_w = $new_h/$r;
}
// note TrueColor does 256 and not.. 8
$dst_img = ImageCreateTrueColor($new_w,$new_h);
ImageCopyResized($dst_img, $src_img, 0,0,0,0, $new_w, $new_h, ImageSX($src_img), ImageSY($src_img));
ImageJpeg($dst_img, $picture);
}
$datazza = gmdate("Y-m-d");
if ($act == 'invia') {
if (($titolo) && ($testo)) {
//********************************** prima immagine ****************************
$image = $_FILES["img"]["tmp_name"];
resize2 ($image , 70);
$imgsiz = getimagesize($_FILES["img"]["tmp_name"]);
$width = $imgsiz[0];
$height = $imgsiz[1];
$type = $_FILES["img"]["type"];
$data1 = @addslashes(@fread(@fopen($_FILES["img"]["tmp_name"], "rb"), $_FILES["img"]["size"]));
//************************RIDIMENSIONA IMG 2 ****************************
$image2 = $_FILES["img2"]["tmp_name"];
resize2 ($image2 , 200);
$imgsiz = getimagesize($_FILES["img2"]["tmp_name"]);
$width2 = $imgsiz[0];
$height2 = $imgsiz[1];
$type2 = $_FILES["img2"]["type"];
$data2 = @addslashes(@fread(@fopen($_FILES["img2"]["tmp_name"], "rb"), $_FILES["img2"]["size"]));
//************************RIDIMENSIONA IMG 3 ****************************
$image3 = $_FILES["img3"]["tmp_name"];
resize2 ($image3 , 200);
$imgsiz = getimagesize($_FILES["img3"]["tmp_name"]);
$width3 = $imgsiz[0];
$height3 = $imgsiz[1];
$type3 = $_FILES["img3"]["type"];
$data3 = @addslashes(@fread(@fopen($_FILES["img3"]["tmp_name"], "rb"), $_FILES["img3"]["size"]));
//************************RIDIMENSIONA IMG 4 ****************************
$image4 = $_FILES["img4"]["tmp_name"];
resize2 ($image4 , 200);
$imgsiz = getimagesize($_FILES["img4"]["tmp_name"]);
$width4 = $imgsiz[0];
$height4 = $imgsiz[1];
$type4 = $_FILES["img4"]["type"];
$data4 = @addslashes(@fread(@fopen($_FILES["img4"]["tmp_name"], "rb"), $_FILES["img4"]["size"]));
$query = "INSERT INTO news VALUES (NULL, '$titolo', '$testo', '$data1', '$width', '$height', '$type', '$data', '$data2', '$width2', '$height2', '$type2', '$data3', '$width3', '$height3', '$type3', '$data4', '$width4', '$height4', '$type4')";
mysql_query ($query)or die("Function Error: ".mysql_error());
header ("location: news.php");
}
}
@include_once("inctop.php");
?>
<style type="text/css">
<!--
/* BEGIN Advanced HTML Editor */
.dmx_btn { width: 22px; height: 22px; border: 1px solid #F2F5FA; margin: 0; padding: 0; background-color: #F2F5FA; }
.dmx_btnOver { width: 22px; height: 22px; border: 1px outset #C4D2E8; background-color: #C4D2E8; }
.dmx_btnDown { width: 22px; height: 22px; border: 1px inset #C4D2E8; background-color: #C4D2E8; }
.dmx_btnNA { width: 22px; height: 22px; border: 1px solid #F2F5FA; background-color: #F2F5FA; filter: alpha(opacity=25); }
.dmx_menuBar { background-color:#F2F5FA; }
/* END Advanced HTML Editor */
-->
</style>
<script language="javascript">
<!--
/* BEGIN Advanced HTML Editor */
var BaseURL = "../";
/* END Advanced HTML Editor */
//-->
</script>
<script language="JavaScript" src="../ScriptLibrary/AdvHTMLEdit.js"></script>
<script language="JavaScript" src="../ScriptLibrary/AdvHTMLLang.js"></script>
<table width="750" border="0" align="center" cellpadding="2" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td height="30" colspan="2" align="center" class="tit">AGGIUNGI NEWS </td>
</tr>
<form name="form1" action="news_add.php?act=invia" enctype="multipart/form-data" method="post">
<tr>
<td width="124">Immagine centrale </td>
<td width="618"><input name="img" type="file" class="input" style='width: 220px;'></td>
</tr>
<tr>
<td>Titolo</td>
<td><input name="titolo" type="text" class="input" id="titolo" style='width: 220px;'></td>
</tr>
<tr>
<td>Data</td>
<td><input name="data" type="text" class="input" id="data" value="<? echo $datazza ?>" style='width: 220px;'></td>
</tr>
<tr>
<td>Testo</td>
<td><textarea dmxedit="true" name="testo" config="language:it"></textarea></td>
</tr>
<tr>
<td>Altra immagine 1 </td>
<td><input name="img2" type="file" class="input" style='width: 220px;'></td>
</tr>
<tr>
<td>Altra immagine 2 </td>
<td><input name="img3" type="file" class="input" style='width: 220px;'></td>
</tr>
<tr>
<td>Altra immagine 3 </td>
<td><input name="img4" type="file" class="input" style='width: 220px;'></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="Submit" type="submit" class="input" value="Invia">
</div></td>
</tr></form>
</table>