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="return valid1"
<my source code is here>
<?
session_start();
ob_start();
set_time_limit(0);
include("includes/vars.inc.php");
include("includes/function.inc.php");
db_connect();
if(isset($_REQUEST['del']) && $_REQUEST['del']==1)
{
$path=$_REQUEST['img'];
$path1=$_REQUEST['img1'];
@unlink($path);
@unlink($path1);
?>
<script type="text/javascript" language="JavaScript">
alert("File has been deleted");
</script>
<?
echo("file has been deleted");
header("location:index.php");
}
if(isset($_FILES['img']))
{
$num=substr(md5(date("His")),0,10);
$img=$num." ".basename( $_FILES['img']['name']);
$_SESSION['img']=$img;
$upath="img_upload/".$img;
$x=@move_uploaded_file($_FILES['img']['tmp_name'], $upath);
$y=@filesize($upath)/1024;
$imgsize=getimagesize($upath);
//if($y<15)
{
//$err_msg="<strong>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="stylesheet/main.css" rel="stylesheet" type="text/css">
<script language="javascript">
function valid12()
{
var ext = document.upload_img.img.value;
if(document.upload_img.img.value !='' )
{
ext = ext.substring(ext.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=JavaScript src="colorpicker/picker.js"></script>
<script language="javascript">
function xmlhttpPost(strURL) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send(getquerystring());
}
function getquerystring() {
var xdir = document.process_img.xdir.value;
var ydir = document.process_img.ydir.value;
var msg = document.process_img.photomsg.value;
var path = document.process_img.path.value;
var col = document.process_img.input1.value;
var size = document.process_img.txtsize.value;
var font = document.process_img.font.value;
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.getElementById("checkavaildiv").innerHTML = str;
}
function createbanner()
{
if(isNaN(document.process_img.xdir.value))
{
alert("Enter number only.");
document.process_img.xdir.focus();
return false;
}
else if(isNaN(document.process_img.ydir.value))
{
alert("Enter number only.");
document.process_img.ydir.focus();
return false;
}
else
xmlhttpPost("test.php");
}
</script>
<script language="javascript">
function sess_del()
{
<?php
//unset($_SESSION['']);
?>
window.location.href="index.php";
}
function valid1()
{
if(document.process_img.xdir.value=="")
{
alert("plz select the x size");
document.process_img.xdir.focus();
return false;
}
if(document.process_img.ydir.value=="")
{
alert("plz select the y size");
document.process_img.ydir.focus();
return false;
}
}
function valid()
{
if(document.upload_img.img.value=="")
{
alert("Please browse image first.");
document.upload_img.img.focus();
return false;
}
if(document.process_img.photomsg.value=="")
{
alert("Enter some text.");
document.process_img.photomsg.focus();
return false;
}
if(document.process_img.size.value==0)
{
alert("Select the size.");
document.process_img.size.focus();
return false;
}
if(document.process_img.material.value==0)
{
alert("Select the material.");
document.process_img.material.focus();
return false;
}
if(document.process_img.quantity.value==0)
{
alert("Please select the qunatity of a product.");
document.process_img.quantity.focus();
return false;
}
}
function changeimg(cat)
{
switch(cat)
{
case 0:
document.getElementById('img11').innerHTML='<img name="fontimg" alt="font1" src="fonts/font1.JPG" width="200" height="50">';
break;
case 1:
document.getElementById('img11').innerHTML='<img name="fontimg" alt="font2" src="fonts/font2.JPG" width="200" height="50">';
break;
case 2:
document.getElementById('img11').innerHTML='<img name="fontimg" alt="font3" src="fonts/font3.JPG" width="200" height="50">';
break;
case 3:
document.getElementById('img11').innerHTML='<img name="fontimg" alt="font4" src="fonts/font4.JPG" width="200" height="50">';
break;
case 4:
document.getElementById('img11').innerHTML='<img name="fontimg" alt="font5" src="fonts/font5.JPG" width="200" height="50">';
break;
case 5:
document.getElementById('img11').innerHTML='<img name="fontimg" alt="font6" src="fonts/font6.JPG" width="200" height="50">';
break;
case 6:
document.getElementById('img11').innerHTML='<img name="fontimg" alt="font7" src="fonts/font7.JPG" width="200" height="50">';
break;
case 7:
document.getElementById('img11').innerHTML='<img name="fontimg" alt="font8" src="fonts/font8.JPG" width="200" height="50">';
break;
case 8:
document.getElementById('img11').innerHTML='<img name="fontimg" alt="font9" src="fonts/font9.JPG" width="200" height="50">';
break;
case 9:
document.getElementById('img11').innerHTML='<img name="fontimg" alt="font10" src="fonts/font10.JPG" width="200" height="50">';
break;
case 10:
document.getElementById('img11').innerHTML='<img name="fontimg" alt="font11" src="fonts/font11.JPG" width="200" height="50">';
break;
case 11:
document.getElementById('img11').innerHTML='<img name="fontimg" alt="font12" src="fonts/font12.JPG" width="200" height="50">';
break;
}
}
</script>
</head>
<body bgcolor="#FFFFFF" 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="#FFFFFF"><table align="center" width="100%" border="0" height="310px">
<tr>
<td width="13px"> </td>
<td valign="top"><table border="0" width="100%">
<tr>
<td width="3%">
<img src="images/1.jpg" align="absmiddle" border="0"></td>
<td width="19%" class="headblue">Upload Photo</td>
<td width="78%"> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><span class="err">
<? if($err_msg) echo $err_msg;?>
</span></td>
</tr>
<tr>
<td> </td>
<td colspan="2">
<form name="upload_img" method="post" action="" enctype="multipart/form-data">
<input type="file" name="img" onChange="return valid12();">
<?
if(isset($_FILES['img']) && !$err_msg)
{ ?>
<input name="img" type="test" value="ghgh"/>
<? }
?>
</form></td>
</tr>
<tr>
<td><img src="images/2.jpg" align="absmiddle" border="0"></td>
<td colspan="2" class="headorange">Choose Poster Specification</td>
</tr>
<form name="process_img" method="post" action="checkout.php" onSubmit="return valid();">
<tr>
<td> </td>
<td></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td valign="top"><table class="four" >
<tr>
<td><?
if(isset($_FILES['img']) && !$err_msg)
{
echo myimage($img,200,200);
}
?>
</td>
</tr>
</table></td>
<td valign="top"><table width="70%" border="0">
<tr>
<td width="25%" valign="top" nowrap><div align="right">Add message to your photo : </div></td>
<td align="left" valign="top"><textarea name="photomsg" style="width:160p" ></textarea>
<input name="input1" type="hidden" id="input1" value="0,0,0" onClick="changeurl();" />
</td>
</tr>
<TR>
<td align="right">Select the text color :</td>
<td><a href="javascript:TCP.popup(document.forms['process_img'].elements['input1'])"><img width="15" height="13" border="0" alt="Click Here to Pick up the color" src="colorpicker/img/sel.gif" /></a></td>
</TR>
<TR>
<td align="right">Select 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">Select the text font :</td>
<td><select name="font" onChange="changeimg(this.selectedIndex)" >
<option value="1.ttf">font1</option>
<option value="2.ttf">font2</option>
<option value="3.ttf">font3</option>
<option value="4.ttf">font4</option>
<option value="5.ttf">font5</option>
<option value="6.ttf">font6</option>
<option value="7.ttf">font7</option>
<option value="8.ttf">font8</option>
<option value="a.ttf">font9</option>
<option value="arriere_garde.ttf">font10</option>
<option value="Linja.ttf">font11</option>
<option value="glidergirls.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">Start your text(X) : </div></td>
<td align="left" valign="top"><input type="text" name="xdir" id="xdir" value="10" style="background:#FFCCFF">
up to
<?=$imgsize[0]/2?>
(Number)</td>
</tr>
<tr>
<td width="25%" valign="top" nowrap><div align="right">Start your text(Y) : </div></td>
<td align="left" valign="top"><input type="text" name="ydir" id="ydir" value="10" style="background:#FFCCFF" onBlur="createbanner();">
up to
<? if($imgsize[1])echo ($imgsize[1]-20);?>
(Number)</td>
</tr>
<tr>
<td valign="top"><div align="right">Size : </div></td>
<td align="left" valign="top"><?
$sql="select * from img_size";
$res=mysql_query($sql);
?>
<select name="size">
<option value="0" selected="selected">__Select__</option>
<?
while($row=mysql_fetch_object($res))
{
echo "<option value='$row->id'>".$row->size." - £".$row->price."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td valign="top"><div align="right">Material : </div></td>
<td valign="top"><?
$sql="select * from material";
$res=mysql_query($sql);
?>
<select name="material">
<option value="0">__Select__</option>
<?
while($row1=mysql_fetch_object($res))
echo "<option value='$row1->id'>".$row1->material." - £".$row1->price."</option>";
?>
</select></td>
</tr>
<tr>
<td valign="top"><div align="right">Quantity : </div></td>
<td valign="top"><select 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"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td colspan="2" align="center"><div id="checkavaildiv">
<?
$_SESSION['imgtemp']=$upath;
if(isset($_FILES['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"> </td>
<td valign="top"> </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"> </td>
</tr>
</table></td>
</tr>
<tr>
<td valign="bottom" height="131"><? include("footer.php"); ?></td>
</tr>
</table>
<!-- End ImageReady Slices -->
</body>
</html>