473,249 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,249 software developers and data experts.

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 2675
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

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

Similar topics

8
by: Beowulf | last post by:
Hi Guru's, I have a query regarding using PHP to maintain a user profiles list. I want to be able to have a form where users can fill in their profile info (Name, hobbies etc) and attach an...
4
by: Kenny | last post by:
I have been trying to write a script that will increase the size of and image when you mouse over it, and decrease it to original size, when you mouse out. After a couple of attempts, this is what...
6
by: Haines Brown | last post by:
I find that when I use list-style-image with galeon or mozilla, padding is inserted between the symbol image and the following list text, while under IE 5.0 it seems to be inserted before the image...
0
by: sakieboy | last post by:
In ASP.Net VB, is there a way to capture a Click on image event? Currently, I have a user control that consists of a button, calendar, and text box. User selects the button and the calendar...
2
by: ganesh kolappan | last post by:
Hi is there any way i can call a clientside function for validation onClick of a Image or imagebutton? Right now my image or imagebutton is submitting to the server, even it return false from...
3
by: Conrad | last post by:
Hi, I was wondering, are there any recommended PHP scrips for performing image code verification? I have found a few but I wanted to check what others are using in this area. Thanks in advance,...
5
by: paulmcnally | last post by:
Hi, I need a javascript RegExp for image file validation from a file upload form. I need to allow image files only (jpeg/jpg/gif/png) can anybody help me please? thanks,
16
by: browntown | last post by:
so I have this application I'm nearly finished with. The only thing the client has requested is the ability to submit the form by pressing "enter". I didn't think this would be a huge pain in the...
9
hsriat
by: hsriat | last post by:
How can I add my validation script to this file upload code? Validation Script:function validate(frm) { if (!/(\.(gif|jpg|jpeg|png))$/i.test(frm.file.value)){ alert('Invalid file...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.