Hi all
I have one problem. I have created one little admin panel. and when i submitted a post and i refresh it again it automatically posts the post again. it posts as many as i click refresh. who can help me to eliminate this problem.
here is my problem.
<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
<?php
include("../config/connect.php");
include("../config/resim.php");
$error = '';
$seher=$_POST['seher'];
$mezmun = $_POST['mezmun'];
$subyekt = $_POST['subyekt'];
$ish=$_POST['place'];
$date=date('Y-m-d');
$no=$_POST['no'];
$haber_kucuk_resim_klasor="../haber_kucuk"; // bu klasorleri acmayi unutmayin
$haber_buyuk_resim_klasor="../haber_buyuk"; // mutlaka bu iki klasore yazma izni vermelisiniz chmod 777
$buyuk_resim_en=640;
$buyuk_resim_boy=480;
$kucuk_resim_en=200;
$kucuk_resim_boy=150;
if(isset($_POST['submit'])) {
if($mezmun == '' || $subyekt == '') {
$error .= 'A required field was left blank.<br />';
echo $error;
return false;
}
if(strlen($_FILES["resim"]["name"])>4)
{// eger resim varsa bu resmi turkce karakterlerden temizledikten sonra
// resim ve kucukresim olmak uzere iki tane resme donusturecegiz
// echo "resim devrede resim=$resim";
$bul=$_FILES["resim"] ;
$bulunacak = array('з','З','э','Э','р','Р','ь','ц','Ю','ю','Ц','Ь',',',' ','(',')','[',']');
$degistir = array('c','C','i','I','g','G','u','o','S','s','O','U','','_','','','','');
$_FILES["resim"]=str_replace($bulunacak, $degistir, $bul);
$resim = "$haber_buyuk_resim_klasor/".$_FILES["resim"]["name"];
move_uploaded_file($_FILES["resim"]["tmp_name"],$resim);
$kucukresim = "$haber_kucuk_resim_klasor/".$_FILES["resim"]["name"];
move_uploaded_file($_FILES["resim"]["tmp_name"],$kucukresim);
// kucuk resmi boyutlandiriyoruz
$icerik = resample($resim,$kucuk_resim_en,$kucuk_resim_boy);
$dosya = fopen ($kucukresim,"w+");
fwrite($dosya,$icerik);
fclose($dosya);
// buyuk resmi boyutlandiriyoruz
$icerik = resample($resim,$buyuk_resim_en,$buyuk_resim_boy);
$dosya = fopen ($resim,"w+");
fwrite($dosya,$icerik);
fclose($dosya);
// resim boyutlandirma bitti
}
if($error == '') {
mysql_query("INSERT INTO jobs VALUES('','$seher', '$mezmun', '$ish','$subyekt', '$date','')");
$mezmun=false;
$subyekt=false;
$date=false;
}
}
?>
<?
if(isset($_POST['duzelt'])){
//$no=$_POST['no'];
$sor=mysql_query("SELECT * FROM jobs where id='$no'");
while($res=mysql_fetch_row($sor)){
$no2=$res[0];
$mezmun2=$res[1];
$subyekt2=$res[2];
}
echo $no;
}
?>
<form name="list" action="" method="POST">
<table width="100%" class="mytable" border="">
<tr bgcolor=#c0c0c0>
<td></td><td>Şəhər</td><td>Vəzifənin adi</td><td>Sahə</td><td>İş yeri</td><td>Qoyulduqu Tarix</td></tr>
<?
if(isset($_POST['show'])){
//$no=$_POST['no'];
$res=mysql_query("select * from jobs where sekil='' ORDER BY id DESC");
function daysDifference($endDate, $beginDate){ //explode the date by "-" and storing to array
$date_parts1=explode("-", $beginDate);
$date_parts2=explode("-", $endDate); //gregoriantojd() Converts a Gregorian date to Julian Day Count
$start_date=gregoriantojd($date_parts1[1], $date_parts1[2], $date_parts1[0]);
$end_date=gregoriantojd($date_parts2[1], $date_parts2[2], $date_parts2[0]);
return $end_date - $start_date;
}
while($sor=mysql_fetch_row($res)){
$id1=$sor[0];
$seher=$sor[1];
$sahe=$sor[2];
$place=$sor[3];
$vezife=$sor[4];
$date=$sor[5];
$datenow1=date('Y-m-d');
$ferq=(int)daysDifference($datenow1,$date);
if($ferq>1){
echo "<tr class=\"row\" id=\"row1\" onmouseover=\"this.className='highlight'; current_row=1\" onmouseout=\"this.className='row'\">
<td id=\"xana0\"><input type=\"checkbox\" id=\"checkbox[]\" name=\"checkbox[]\" value=\"$id1\"><input type=\"submit\" name=\"delete\" value=\"POZ\"></td><td id=\"xana0\">".$seher."</td><td width=330px id=\"xana1\"><a href='#' class=\"li\">".$vezife."</a></td><td width=170 id=\"xana1\">".$sahe."</td><td width=350 id=\"xana1\">".$place."</td><td id=\"xana2\">".$date."</td>
</tr>";
}
else {
echo "<tr class=\"row\" id=\"row1\" onmouseover=\"this.className='highlight'; current_row=1\" onmouseout=\"this.className='row'\">
<td id=\"xana0\"><input type=\"checkbox\" id=\"checkbox[]\" name=\"checkbox[]\" value=\"$id1\" ><input type=\"submit\" name=\"delete\" value=\"POZ\"></td><td id=\"xana1\">".$seher."</td><td width=330px id=\"xana1\"><a href='#' class=\"li\">".$vezife."</a></td><td width=170 id=\"xana1\">".$sahe."</td><td width=350 id=\"xana1\">".$place."</td><td class=\"tarix\" id=\"xana2\">bu gun</td>
</tr>";
}
}
}
?>
<?
if(isset($_POST['delete'])){
$checkbox=$_POST['checkbox']; //from name="checkbox[]"
$countCheck=count($_POST['checkbox']);
for($i=0;$i<$countCheck;$i++)
{
$del_id=$checkbox[$i];
echo $del_id;
$sql = "DELETE from jobs where id=$del_id";
$result = mysql_query($sql);
}
if($result)
{
echo "successful delete";
}
else
{
echo "Error: ".mysql_error();
}
}
?>
</table>
</form>
<table>
<form name="enter" action="" method="POST" enctype="multipart/form-data">
<tr><td>Şəhər:</td><td><select name="seher" id="seher">
<option default value=""></option>
<option name="Baki" value="baki">Baki</option>
<option name="Sumqayıt" value="sumqayıt">Sumqayıt</option>
<option name="Gəncə" value="gəncə">Gəncə</option>
<option name="Lənkəran" value="lənkəran">Lənkəran</option>
<option name="Sabirabad" value="sabirabad">Sabirabad</option></select></td></tr>
<tr><td>Vezifenin adi:</td><td> <input type="text" name="subyekt" width="100" maxlength="100" value="<? echo $subyekt2; ?>"></td></tr>
<tr><td>Sahe: </td><td><input type="text" name="mezmun" width="100" maxlength="50" value="<? echo $mezmun2; ?>"/></td></tr>
<tr><td>Iş yeri:</td><td> <input type="text" name="place" width="100" maxlength="100" value="<? echo $place2; ?>"></td></tr><br />
<tr><td>Sekil: </td><td><input type="file" name="resim" /></td></tr><br/>
<tr><td>News:</td><td> <textarea name="news" cols="60" rows="6" class="Formstyles"></textarea></td></tr>
<tr><td><input class="Formstyles" name="submit" type="submit" value="Add" onClick="yoxla();"/>
<input class="Formstyles" name="duzelt" type="submit" value="deyis" /><td><input class="Formstyles" name="show" type="submit" value="goster" />
<input class="Formstyles" name="delete" id="delete" type="submit" value="poz" /></td></tr></td>
<tr><td>istedyini xeberi sec:</td><td>
<select name="no" id="no">
<OPTION SELECTED VALUE="">Select...</OPTION>
<?
$sorgu=mysql_query("SELECT * FROM jobs");
while($satir=mysql_fetch_array($sorgu))
{
echo "<option value='$satir[0]'>$satir[1]</option>";
}
?>
</select></td></tr></table>
</form></body>
</html>
thanks for attention