form.php
<?php session_start(); ?>
<form action="form_pro.php" method="post" enctype="multipart/form-data" style="font-size:10px;">
<?php
if (isset($_SESSION['o_e']['iname']))
{
echo '<span class="alert alert-danger">'.$_SESSION['o_e']['iname'].'</span>';
}
if (isset($_SESSION['o_e']['req']))
{
echo '<span class="alert alert-danger">'.$_SESSION['o_e']['req'].'</span>';
}
if (isset($_SESSION['o_e']['wro']))
{
echo '<span class="alert alert-danger">'.$_SESSION['o_e']['wro'].'</span>';
}
if (isset($_SESSION['o_e']['up']))
{
echo '<span class="alert alert-success">'.$_SESSION['o_e']['up'].'</span>';
}
unset($_SESSION['o_e']);
?>
<input type="file" name="o_img" class="form-control">
<br/>
<input type="text" name="i_nm" class="form-control" placeholder="Enter Image Name"/>
<br/>
<input type="submit" value=" Upload " class="btn btn-success">
</form>
form_pro.php
<?php session_start();
$_SESSION['o_e']=array();
extract($_POST);
if (empty($_POST['i_nm']))
{
$_SESSION['o_e']['iname']="Enter Image Name";
header('location:form_pro.php');
}
if (!empty($_SESSION['o_e']))
{
header('location:form_pro.php');
}
else
{
if (empty($_FILES['o_img']['name']))
{
$_SESSION['o_e']['req']="First Fill all Details";
header('location:form_pro.php');
}
else
{
$ext=strtolower(substr($_FILES['o_img']['name'],-4));
if(!($ext==".jpg" || $ext==".jpe" || $ext=="jpeg" || $ext==".png" || $ext==".bmp" || $ext==".gif"))
{
$_SESSION['o_e']['wro']="Wrong File Selected";
header('location:form_pro.php');
}
else
{
$iname=time().$_FILES['o_img']['name'];
$iname=str_replace(" ","_", $iname);
move_uploaded_file($_FILES['o_img']['tmp_name'],"image/gallary/".$iname);
extract($_POST);
$link=mysql_connect('localhost','root','');
mysql_select_db('song_admin',$link);
$query="insert into header_image
(iname,i_nm)
values
('$iname','$i_nm')";
mysql_query($query,$link);
$_SESSION['o_e']['up']="Image is Uploading";
header('location:form_pro.php');
}
}
}
?>
<?php session_start(); ?>
<form action="form_pro.php" method="post" enctype="multipart/form-data" style="font-size:10px;">
<?php
if (isset($_SESSION['o_e']['iname']))
{
echo '<span class="alert alert-danger">'.$_SESSION['o_e']['iname'].'</span>';
}
if (isset($_SESSION['o_e']['req']))
{
echo '<span class="alert alert-danger">'.$_SESSION['o_e']['req'].'</span>';
}
if (isset($_SESSION['o_e']['wro']))
{
echo '<span class="alert alert-danger">'.$_SESSION['o_e']['wro'].'</span>';
}
if (isset($_SESSION['o_e']['up']))
{
echo '<span class="alert alert-success">'.$_SESSION['o_e']['up'].'</span>';
}
unset($_SESSION['o_e']);
?>
<input type="file" name="o_img" class="form-control">
<br/>
<input type="text" name="i_nm" class="form-control" placeholder="Enter Image Name"/>
<br/>
<input type="submit" value=" Upload " class="btn btn-success">
</form>
form_pro.php
<?php session_start();
$_SESSION['o_e']=array();
extract($_POST);
if (empty($_POST['i_nm']))
{
$_SESSION['o_e']['iname']="Enter Image Name";
header('location:form_pro.php');
}
if (!empty($_SESSION['o_e']))
{
header('location:form_pro.php');
}
else
{
if (empty($_FILES['o_img']['name']))
{
$_SESSION['o_e']['req']="First Fill all Details";
header('location:form_pro.php');
}
else
{
$ext=strtolower(substr($_FILES['o_img']['name'],-4));
if(!($ext==".jpg" || $ext==".jpe" || $ext=="jpeg" || $ext==".png" || $ext==".bmp" || $ext==".gif"))
{
$_SESSION['o_e']['wro']="Wrong File Selected";
header('location:form_pro.php');
}
else
{
$iname=time().$_FILES['o_img']['name'];
$iname=str_replace(" ","_", $iname);
move_uploaded_file($_FILES['o_img']['tmp_name'],"image/gallary/".$iname);
extract($_POST);
$link=mysql_connect('localhost','root','');
mysql_select_db('song_admin',$link);
$query="insert into header_image
(iname,i_nm)
values
('$iname','$i_nm')";
mysql_query($query,$link);
$_SESSION['o_e']['up']="Image is Uploading";
header('location:form_pro.php');
}
}
}
?>