Monday 2 September 2013

display image in registration form

//Display Image in Registration Form

//image_form.php

<html>
<body>
<fieldset>
<legend>Customer Details</legend>
<form action="action.php" enctype="multipart/form-data"
method="post">
<table>
<tr>
<td><label>Name:</label></td>
<td><input name="name" type="text" /></td>
</tr>
<tr>
<td><label>Phone No:</label></td>
<td><input name="phone" type="text" id="phone" /></td>
</tr>
<tr>
<td><label>Email Id:</label></td>
<td><input name="email" type="text" id="email" /></td>
</tr>
<tr>
<td><label>Address:</label></td>
<td><input name="address" type="text" id="address" /></td>
</tr>
<tr>
<td><label>Country:</label></td>
<td><input name="con" type="text" id="con" /></td>
</tr>
<tr>
<td><label>Select your photo:</label></td>
<td><input name="image" type="file" /></td>
</tr>
<tr>
<td><input type="submit" value="submit" /></td>
</tr>
</table>
</form>
</fieldset>
</body>
</html>

//...............................................................................................................................................
//Action.php

<html>
<body>
<?php
 $sname=$_POST['name'];
 $phone=$_POST['phone'];
 $email=$_POST['email'];
 $address=$_POST['address'];
 $contry=$_POST['con'];
 extract($_FILES['image']);
 /*print_r($_FILES);*/
 if($error==0)
 {
   if(($type="image/jpeg")||$type="image/pjpeg")
   {
    if(($size)/1024<=1000)
    {
     $path="upload";
     $filename=rand(1,1000)."_".$name;
     $act_path=$path."/".$filename;
     copy($tmp_name,$act_path);
     $f=1;
    }
    else
    {
     $msz="its too large! i can't handle it.";
    }
   }
   else
   {
    $msz="Opps! your file is not valid";
   }
 }
else
{
$msz="Error in the file!!";
}
if($f==1)
{
?>
<div style="width:550px;margin:0 auto;
padding:10px;background-color:#69F;
height:130px;box-shadow:#000 0 0 10px;">
<div style="float:right;border:1px solid #ccc;
padding:1px 2px;width:130px;
box-shadow:#aaa 0 0 10px;">
<?php
echo "<img src=\"$act_path\" height=100/>";
?>
</div>
<div style="float:left;padding-right:5px;">
<table style="text-align:left;color:#ffffff;
font-weight:bold;text-shadow:1px 1px #aaa;">
<tr>
<td>Name:</td>
<td style="text-align:left;color:yellow;">
<?php echo $sname; ?></td>
</tr>
<tr>
<td>Phone No:</td>
<td style="text-align:left;color:yellow;">
<?php echo $phone; ?></td>
</tr>
<tr>
<td>Email Id:</td>
<td style="text-align:left;color:yellow;">
<?php echo $email; ?></td>
</tr>
<tr>
<td>Address:</td>
<td style="text-align:left;color:yellow;">
<?php echo $address; ?></td>
</tr>
<tr>
<td>Country:</td>
<td style="text-align:left;color:yellow;">
<?php echo $contry; ?></td>
</tr>
</table>
</div>
</div>
<?php
}
else
{
header("location:image_form.php?data=$msz");
}
?>
</body>

</html>

No comments:

Post a Comment