Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to store date to database

Answer Posted / sekar

<?php
include_once("config/dbcon.php");
admin_html();
if($_POST['submit']=='INSERT'){
admin_insert();
}
elseif($_GET['type']=='list'){
$id=0;
$cl_name=0;$cl_place=0;$cl_site=0;$cl_logo=0;$cl_category=0;
admin_list($id,$cl_name,$cl_place,$cl_site,$cl_logo,$cl_category);
}
elseif($_GET['type']=='del'){
admin_delete();
}
elseif($_GET['type']=='update'){
admin_update();
}
function admin_html(){
$display = "<form method='post' action=''
enctype='multipart/form-data'>
<table align='center' border='1' cellpadding='10'
cellspacing='5' width='700'>
<tr>
<td width='100%' align='center' colspan='3'><h3>College
information</h3></td>
</tr>
<tr>
<td width='40%' align='center'>College Name</td>
<td width='10%' align='center'>:</td>
<td width='50%' align='center'><input type='text'
name='cl_name'></td>
</tr>
<tr>
<td width='40%' align='center'>College Place</td>
<td width='10%' align='center'>:</td>
<td width='50%' align='center'><input type='text'
name='cl_place'></td>
</tr>
<tr>
<td width='40%' align='center'>College site</td>
<td width='10%' align='center'>:</td>
<td width='50%' align='center'><input type='text'
name='cl_site'></td>
</tr>
<tr>
<td width='40%' align='center'>College Category</td>
<td width='10%' align='center'>:</td>
<td width='50%' align='center'>
<select name='cl_cat'>
<option value='-1'>Please Select anyone</option>
<option value='mediacl'>Medical</option>
<option value='art'>Art</option>
<option value='engg'>Engg</option>
</select>
</td>
</tr>
<tr>
<td width='40%' align='center'>College Logo</td>
<td width='10%' align='center'>:</td>
<td width='50%' align='center'><input type='file'
name='cl_logo'></td>
</tr>
<tr>
<td width='50%' align='center' colspan='2'><input
type='submit' value='INSERT' name='submit'></td>
<td width='50%' align='center'><a
href='admin.php?type=list'>EDIT</a></td>
</tr>";
echo $display;
}

function admin_insert(){
$cn = $_POST["cl_name"];
$cp = $_POST["cl_place"];
$cs = $_POST["cl_site"];
$cc = $_POST["cl_cat"];
$cl = admin_upload();

$select = "select cl_name, cl_place, cl_site from
collegeinformation";
$row = mysql_query($select);
$count = mysql_num_rows($row);

$insert = "insert into collegeinformation(cl_name,
cl_place, cl_site,
cl_logo,cl_category)values('$cn','$cp','$cs','$cc','$cl')";
$result = mysql_query($insert);

if($insert){
echo "1 record added";
}
else{
echo "No record added";
}


}

function admin_upload(){
$name = $_FILES['cl_logo']['name'];
$type = $_FILES['cl_logo']['type'];
$size = $_FILES['cl_logo']['size'];
$tmp= $_FILES['cl_logo']['tmp_name'];
$err = $_FILES['cl_logo']['error'];

if(($type="image/jpeg")||($type="image/gif")){

if($err>0){
echo "Error in file";
}
else{

$target_path = "images/";
$target_path = $target_path.$name;

if(move_uploaded_file($tmp,$target_path)){

echo "success";
}
else{

echo "failure";
}
}

return $target_path;

}
else{
echo "invalid File";
}
}

function
admin_list($id,$cl_name,$cl_place,$cl_site,$cl_logo,$cl_category){
$pagenum= $_GET['pagenum'];
$display_list = "";
$display_list .= "<form method='post'><table align='center'
border='1' cellpadding='8' cellspacing='2' width='700'>
<tr>
<td width='100%' align='center' colspan='8'>
<h3>list College information</h3>
</td>
</tr>
<tr>
<td width='5%' align='center'>ID</td><td width='10%'
align='center'>Name</td><td width='10%'
align='center'>Place</td><td width='10%'
align='center'>Site</td><td width='25%'
align='center'>Logo</td><td width='15%'
align='center'>category</td><td width='15%'
align='center'>DELETE</td><td width='10%'
align='center'>UPDATE</td>
</tr>
";
$pagenum = $_GET['pagenum']>0?$_GET['pagenum']:0;
if($id!=0){
echo "sekar";
$update = "update collegeinformation set
cl_name='$cl_name', cl_place='$cl_place',cl_site='$cl_site'
where id='$id'";
$up = mysql_query($update);
}
$select = "select
id,cl_name,cl_place,cl_site,cl_logo,cl_category from
collegeinformation";
$result = mysql_query($select);
while($res = mysql_fetch_array($result)){
$display_list .="<tr>
<td width='5%' align='center'>$res[0]</td><td width='10%'
align='center'>$res[1]</td><td width='10%'
align='center'>$res[2]</td><td width='10%'
align='center'>$res[3]</td><td width='25%'
align='center'>$res[4]</td><td width='15%'
align='center'>$res[5]</td><td width='15%' align='center'><a
href='admin.php?type=del&id=$res[0]&url=$res[5]'>DELETE</a></td><td
width='10%' align='center'><a
href='admin.php?type=update&id=$res[0]'>UPDATE</a></td>
</tr>";
}

$display_list .= "</table></form>";

echo $display_list;

}

function admin_delete(){

$id = $_GET['id'];
$url = unlink($_GET['url']);

$delete = "delete from collegeinformation where id ='$id'";

$result = mysql_query($delete);

if($result){

echo "1 record deleted";
}
else{

echo "Not deleted";
}

}

function admin_update(){

$id = $_GET['id'];

$select = "select id, cl_name, cl_place, cl_site from
collegeinformation where id='$id'";

$result = mysql_query($select);

while($res = mysql_fetch_array($result)){

$display_update .= "<form method='post' action=''
enctype='multipart/form-data'>
<table align='center' border='1' cellpadding='10'
cellspacing='5' width='700'>
<tr>
<td width='100%' align='center' colspan='3'><h3>College
information</h3></td>
</tr>
<tr>
<td width='40%' align='center'>College Name</td>
<td width='10%' align='center'>:</td>
<td width='50%' align='center'><input type='text'
name='cl_name' value='$res[1]'></td>
</tr>
<tr>
<td width='40%' align='center'>College Place</td>
<td width='10%' align='center'>:</td>
<td width='50%' align='center'><input type='text'
name='cl_place' value='$res[2]'></td>
</tr>
<tr>
<td width='40%' align='center'>College site</td>
<td width='10%' align='center'>:</td>
<td width='50%' align='center'><input type='text'
name='cl_site' value='$res[3]'></td>
</tr>
<tr>
<td width='100%' align='center' colspan='3'><input
type='submit' name='submit' value='UPDATE'></td>
</tr>
</table></form>";
echo $display_update;

if($_POST['submit']=='UPDATE'){


admin_list($res[0],$_POST['cl_name'],$_POST['cl_place'],$_POST['cl_site'],$res[4],$res[5]);
}

}



}
?>

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does it mean when it says the csrf token is invalid?

903


Which method removes the last element from the end of an array?

965


What is self in php?

1148


How to protect special characters in query string?

966


How to redirect https to http url through .htaccess?

963


Tell me what does the scope of variables means?

943


What is use of header() function in php?

1029


Why many companies are switching their current business language to php? Where php basically used?

953


What is file upload?

1072


What is an operator in php?

1052


How can we execute a php script using command line?

1049


How can php and html interact?

1051


How to read a file in binary mode?

1112


What are the string function in php?

975


What are the different types of PHP arrays?

1079