hi, friend. i have a problem in image validation plz check it.
i have to include a image validation in foam 1. but i sending a details through form2.
But when i include a image validation in foam1, then i can not change my image on
calling a function onchange="retur n valid1"
<my source code is here>
<?
session_start() ;
ob_start();
set_time_limit( 0);
include("includ es/vars.inc.php");
include("includ es/function.inc.ph p");
db_connect();
if(isset($_REQU EST['del']) && $_REQUEST['del']==1)
{
$path=$_REQUEST['img'];
$path1=$_REQUES T['img1'];
@unlink($path);
@unlink($path1) ;
?>
<script type="text/javascript" language="JavaS cript">
alert("File has been deleted");
</script>
<?
echo("file has been deleted");
header("locatio n:index.php");
}
if(isset($_FILE S['img']))
{
$num=substr(md5 (date("His")),0 ,10);
$img=$num." ".basename( $_FILES['img']['name']);
$_SESSION['img']=$img;
$upath="img_upl oad/".$img;
$x=@move_upload ed_file($_FILES['img']['tmp_name'], $upath);
$y=@filesize($u path)/1024;
$imgsize=getima gesize($upath);
//if($y<15)
{
//$err_msg="<stro ng>File must be more than 150 kb.</strong>";
//@unlink($upath) ;
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="styleshee t/main.css" rel="stylesheet " type="text/css">
<script language="javas cript">
function valid12()
{
var ext = document.upload _img.img.value;
if(document.upl oad_img.img.val ue !='' )
{
ext = ext.substring(e xt.length-3,ext.length);
ext = ext.toLowerCase ();
if(ext != 'jpg')
{
alert('You upload a '+ext+
' file please upload only jpg image.');
return false;
}
else
{
document.upload _img.submit();
}
}
return true;
}
</script>
<link rel="stylesheet " href="js/lightbox.css" type="text/css" media="screen" />
<script language=JavaSc ript src="colorpicke r/picker.js"></script>
<script language="javas cript">
function xmlhttpPost(str URL) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttp Request) {
self.xmlHttpReq = new XMLHttpRequest( );
}
// IE
else if (window.ActiveX Object) {
self.xmlHttpReq = new ActiveXObject(" Microsoft.XMLHT TP");
}
self.xmlHttpReq .open('POST', strURL, true);
self.xmlHttpReq .setRequestHead er('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq .onreadystatech ange = function() {
if (self.xmlHttpRe q.readyState == 4) {
updatepage(self .xmlHttpReq.res ponseText);
}
}
self.xmlHttpReq .send(getquerys tring());
}
function getquerystring( ) {
var xdir = document.proces s_img.xdir.valu e;
var ydir = document.proces s_img.ydir.valu e;
var msg = document.proces s_img.photomsg. value;
var path = document.proces s_img.path.valu e;
var col = document.proces s_img.input1.va lue;
var size = document.proces s_img.txtsize.v alue;
var font = document.proces s_img.font.valu e;
qstr = 'xdir=' + escape(xdir) + '&ydir=' + escape(ydir) + '&msg=' + escape(msg) + '&path=' + escape(path) + '&col=' + escape(col) + '&size=' + escape(size) + '&font=' + escape(font); // NOTE: no '?' before querystring
//alert(qstr);
return qstr;
}
function updatepage(str) {
document.getEle mentById("check availdiv").inne rHTML = str;
}
function createbanner()
{
if(isNaN(docume nt.process_img. xdir.value))
{
alert("Enter number only.");
document.proces s_img.xdir.focu s();
return false;
}
else if(isNaN(docume nt.process_img. ydir.value))
{
alert("Enter number only.");
document.proces s_img.ydir.focu s();
return false;
}
else
xmlhttpPost("te st.php");
}
</script>
<script language="javas cript">
function sess_del()
{
<?php
//unset($_SESSION['']);
?>
window.location .href="index.ph p";
}
function valid1()
{
if(document.pro cess_img.xdir.v alue=="")
{
alert("plz select the x size");
document.proces s_img.xdir.focu s();
return false;
}
if(document.pro cess_img.ydir.v alue=="")
{
alert("plz select the y size");
document.proces s_img.ydir.focu s();
return false;
}
}
function valid()
{
if(document.upl oad_img.img.val ue=="")
{
alert("Please browse image first.");
document.upload _img.img.focus( );
return false;
}
if(document.pro cess_img.photom sg.value=="")
{
alert("Enter some text.");
document.proces s_img.photomsg. focus();
return false;
}
if(document.pro cess_img.size.v alue==0)
{
alert("Select the size.");
document.proces s_img.size.focu s();
return false;
}
if(document.pro cess_img.materi al.value==0)
{
alert("Select the material.");
document.proces s_img.material. focus();
return false;
}
if(document.pro cess_img.quanti ty.value==0)
{
alert("Please select the qunatity of a product.");
document.proces s_img.quantity. focus();
return false;
}
}
function changeimg(cat)
{
switch(cat)
{
case 0:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font1" src="fonts/font1.JPG" width="200" height="50">';
break;
case 1:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font2" src="fonts/font2.JPG" width="200" height="50">';
break;
case 2:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font3" src="fonts/font3.JPG" width="200" height="50">';
break;
case 3:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font4" src="fonts/font4.JPG" width="200" height="50">';
break;
case 4:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font5" src="fonts/font5.JPG" width="200" height="50">';
break;
case 5:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font6" src="fonts/font6.JPG" width="200" height="50">';
break;
case 6:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font7" src="fonts/font7.JPG" width="200" height="50">';
break;
case 7:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font8" src="fonts/font8.JPG" width="200" height="50">';
break;
case 8:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font9" src="fonts/font9.JPG" width="200" height="50">';
break;
case 9:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font10" src="fonts/font10.JPG" width="200" height="50">';
break;
case 10:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font11" src="fonts/font11.JPG" width="200" height="50">';
break;
case 11:
document.getEle mentById('img11 ').innerHTML='< img name="fontimg" alt="font12" src="fonts/font12.JPG" width="200" height="50">';
break;
}
}
</script>
</head>
<body bgcolor="#FFFFF F" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0 " bottommargin="0 ">
<!-- ImageReady Slices (layout.psd) -->
<table id="Table_01" width="1000" cellpadding="0" cellspacing="0" align="center" class="fourbr">
<tr>
<td valign="top" height="165"><? include("header .php");?></td>
</tr>
<tr>
<td valign="top" bgcolor="#FFFFF F"><table align="center" width="100%" border="0" height="310px">
<tr>
<td width="13px">&n bsp;</td>
<td valign="top"><t able border="0" width="100%">
<tr>
<td width="3%">
<img src="images/1.jpg" align="absmiddl e" border="0"></td>
<td width="19%" class="headblue ">Upload Photo</td>
<td width="78%">&nb sp;</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><sp an class="err">
<? if($err_msg) echo $err_msg;?>
</span></td>
</tr>
<tr>
<td> </td>
<td colspan="2">
<form name="upload_im g" method="post" action="" enctype="multip art/form-data">
<input type="file" name="img" onChange="retur n valid12();">
<?
if(isset($_FILE S['img']) && !$err_msg)
{ ?>
<input name="img" type="test" value="ghgh"/>
<? }
?>
</form></td>
</tr>
<tr>
<td><img src="images/2.jpg" align="absmiddl e" border="0"></td>
<td colspan="2" class="headoran ge">Choose Poster Specification</td>
</tr>
<form name="process_i mg" method="post" action="checkou t.php" onSubmit="retur n valid();">
<tr>
<td> </td>
<td></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td valign="top"><t able class="four" >
<tr>
<td><?
if(isset($_FILE S['img']) && !$err_msg)
{
echo myimage($img,20 0,200);
}
?>
</td>
</tr>
</table></td>
<td valign="top"><t able width="70%" border="0">
<tr>
<td width="25%" valign="top" nowrap><div align="right">A dd message to your photo :&nb sp; </div></td>
<td align="left" valign="top"><t extarea name="photomsg" style="width:16 0p" ></textarea>
<input name="input1" type="hidden" id="input1" value="0,0,0" onClick="change url();" />
</td>
</tr>
<TR>
<td align="right">S elect the text color :</td>
<td><a href="javascrip t:TCP.popup(doc ument.forms['process_img'].elements['input1'])"><img width="15" height="13" border="0" alt="Click Here to Pick up the color" src="colorpicke r/img/sel.gif" /></a></td>
</TR>
<TR>
<td align="right">S elect the text size :</td>
<td><select name="txtsize" >
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
<option value="40">40</option>
<option value="50">50</option>
</select>
</td>
</TR>
<TR>
<td align="right">S elect the text font :</td>
<td><select name="font" onChange="chang eimg(this.selec tedIndex)" >
<option value="1.ttf">f ont1</option>
<option value="2.ttf">f ont2</option>
<option value="3.ttf">f ont3</option>
<option value="4.ttf">f ont4</option>
<option value="5.ttf">f ont5</option>
<option value="6.ttf">f ont6</option>
<option value="7.ttf">f ont7</option>
<option value="8.ttf">f ont8</option>
<option value="a.ttf">f ont9</option>
<option value="arriere_ garde.ttf">font 10</option>
<option value="Linja.tt f">font11</option>
<option value="glidergi rls.ttf">font12 </option>
</select>
<table class="four" >
<tr>
<td><span id="img11">
<img name="fontimg" src="fonts/font1.JPG" width="200" height="50">
</span>
</td>
</tr>
</table> </td>
</TR>
<tr>
<td width="25%" valign="top" nowrap><div align="right">S tart your text(X) :& nbsp; </div></td>
<td align="left" valign="top"><i nput type="text" name="xdir" id="xdir" value="10" style="backgrou nd:#FFCCFF">
up to
<?=$imgsize[0]/2?>
(Number)</td>
</tr>
<tr>
<td width="25%" valign="top" nowrap><div align="right">S tart your text(Y) :& nbsp; </div></td>
<td align="left" valign="top"><i nput type="text" name="ydir" id="ydir" value="10" style="backgrou nd:#FFCCFF" onBlur="createb anner();">
up to
<? if($imgsize[1])echo ($imgsize[1]-20);?>
(Number)</td>
</tr>
<tr>
<td valign="top"><d iv align="right">S ize :  ;</div></td>
<td align="left" valign="top"><?
$sql="select * from img_size";
$res=mysql_quer y($sql);
?>
<select name="size">
<option value="0" selected="selec ted">__Select__ </option>
<?
while($row=mysq l_fetch_object( $res))
{
echo "<option value='$row->id'>".$row->size." - £".$ro w->price."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td valign="top"><d iv align="right">M aterial :& nbsp;</div></td>
<td valign="top"><?
$sql="select * from material";
$res=mysql_quer y($sql);
?>
<select name="material" >
<option value="0">__Sel ect__</option>
<?
while($row1=mys ql_fetch_object ($res))
echo "<option value='$row1->id'>".$row1->material." - £".$ro w1->price."</option>";
?>
</select></td>
</tr>
<tr>
<td valign="top"><d iv align="right">Q uantity :& nbsp;</div></td>
<td valign="top"><s elect name="quantity" >
<option value="0" >0</option>
<?
for($i=1;$i<=25 ;$i++)
echo "<option value='$i'>$i</option>";
?>
</select></td>
</tr>
<tr>
<td valign="top">&n bsp;</td>
<td valign="top">&n bsp;</td>
</tr>
<tr>
<td colspan="2" align="center"> <div id="checkavaild iv">
<?
$_SESSION['imgtemp']=$upath;
if(isset($_FILE S['img']) && !$err_msg)
{
echo "<input type='hidden' name='path' value='".$upath ."'>";
?>
<a href="index.php ?del=1&img=<?=$ upath; ?>">Delete Image</a>
<? }?>
</div></td>
</tr>
<tr>
<td valign="top">&n bsp;</td>
<td valign="top">&n bsp;</td>
</tr>
<tr>
<td colspan="4" align="center" valign="top">
<input type="submit" name="order" value="Continue to Checkout">
<input type="button" name="cancel" value="Cancel"
onClick="return sess_del();"></td>
</tr>
</table></td>
</tr>
</form>
</table></td>
<td width="13px">&n bsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td valign="bottom" height="131"><? include("footer .php"); ?></td>
</tr>
</table>
<!-- End ImageReady Slices -->
</body>
</html>