469,623 Members | 1,850 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

image validation

5
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">&nbsp;</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%">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="2"><span class="err">
<? if($err_msg) echo $err_msg;?>
</span></td>
</tr>
<tr>
<td>&nbsp;</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>&nbsp;</td>
<td></td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</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&nbsp;:&nbsp; </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)&nbsp;:&nbsp; </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)&nbsp;:&nbsp; </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&nbsp;:&nbsp;</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." - &pound;".$row->price."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td valign="top"><div align="right">Material&nbsp;:&nbsp;</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." - &pound;".$row1->price."</option>";
?>
</select></td>
</tr>
<tr>
<td valign="top"><div align="right">Quantity&nbsp;:&nbsp;</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">&nbsp;</td>
<td valign="top">&nbsp;</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."'>";
?>
&nbsp;&nbsp; <a href="index.php?del=1&img=<?=$upath; ?>">Delete Image</a>
<? }?>
</div></td>
</tr>
<tr>
<td valign="top">&nbsp;</td>
<td valign="top">&nbsp;</td>
</tr>
<tr>
<td colspan="4" align="center" valign="top">
<input type="submit" name="order" value="Continue to Checkout">
&nbsp; &nbsp;
<input type="button" name="cancel" value="Cancel"
onClick="return sess_del();"></td>
</tr>
</table></td>
</tr>
</form>
</table></td>
<td width="13px">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td valign="bottom" height="131"><? include("footer.php"); ?></td>
</tr>
</table>
<!-- End ImageReady Slices -->
</body>
</html>
Jul 28 '07 #1
4 2486
pbmods
5,821 Expert 4TB
Heya, yatin. Welcome to TSDN!

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Jul 28 '07 #2
yatin
5
If have a two foams in my file
one is this
example....

<--------------------------------------------------------------------------------------------------------------->
<form name="upload_img" method="post" action="" enctype="multipart/form-data">
<--------------------------------------------------------------------------------------------------------------->
And 2nd fom is this
<--------------------------------------------------------------------------------------------------------------->
<form name="process_img" method="post" action="checkout.php" onSubmit="return valid();">
<--------------------------------------------------------------------------------------------------------------->

Now my problem is that when i submit the foam2, the image validation in my foam1 is not worked.
And i make is worked then i can not browse another image in foam1.

check it on this URl

http://acetechnologiesnet.com/scripts/createurposter/index.php
Jul 28 '07 #3
kovik
1,044 Expert 1GB
You are hardly making sense. Maybe you need to reword.

FYI, you can't submit more than one form on the same page.
Jul 28 '07 #4
pbmods
5,821 Expert 4TB
Heya, yatin.

You might want to combine the two form processors into a single file.

Or, you can make it a two-step process, where the User Uploads the image first, and if the image checks out, he is then taken to the checkout form page.
Jul 28 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by Beowulf | last post: by
4 posts views Thread by Kenny | last post: by
6 posts views Thread by Haines Brown | last post: by
reply views Thread by sakieboy | last post: by
2 posts views Thread by ganesh kolappan | last post: by
3 posts views Thread by Conrad | last post: by
5 posts views Thread by paulmcnally | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.