I need your helps.
When i was refreshing my script aftering post data
repeat insert data mysql.how to clear post data after post data ?
thanks ....
Code: Select all
<?php
session_start();
if(!session_is_registered('username')){ // if session variable "username" does not exist.
header("location:index.php");
}else {
?>
<?php
include("connect.php");
$tbl_name = "articles";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$dbname")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
<title>Makale Yönetim Paneli</title>
<style type="text/css">
<!--
.style23 {color: #FF0000}
a:link {
color: #FFFF00;
}
a:visited {
color: #FFFF00;
}
a:hover {
color: #FFFF00;
}
a:active {
color: #FFFF00;
}
-->
</style>
</head>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px;
}
body {
background-color: #000000;
}
a {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000099;
font-weight: bold;
}
.style15 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color: #FFFFFF; }
.style19 {font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; color: #FF6600; font-weight: bold; }
.style22 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #FFFFFF;
font-weight: bold;
}
.style24 {color: #FFFF00}
-->
</style>
<body>
<p>Merhaba <?php echo $_SESSION['username'];?>! Web Site Yönetim Paneli'ne ho?geldin </p>
<p><a href="index.php">Ç?k?? yap</a></p>
<p align="left" class="style19 style23">Makale Düzeni</p>
<table width="807" border="0" cellpadding="2" cellspacing="2" bordercolor="#FFFFFF" bgcolor="#FF0000">
<tr>
<td colspan="10" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style22">Makale Ayarlar?</span></td>
</tr>
<tr>
<td width="17" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style15"><strong>ID</strong></span></td>
<td width="95" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style15"><strong>Makale Ad?</strong></span></td>
<td width="90" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style15"><strong>Makale Resmi</strong></span></td>
<td width="119" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style15"><strong>Makale K?sa Aç?klama</strong></span></td>
<td width="120" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style15"><strong>Makale Aç?klama</strong></span></td>
<td width="72" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style15"><strong>Makale Tarihi</strong></span></td>
<td width="93" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style15"><strong>Harici Ba?lant?</strong></span></td>
<td width="56" align="center" valign="middle" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style15"><strong>Güncelle</strong></span></td>
<td width="28" align="center" valign="middle" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style15"><strong>Sil</strong></span></td>
<td width="55" align="center" valign="middle" nowrap bordercolor="#FF0000" bgcolor="#000000">Durum</td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td width="17" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style23"><?php echo $rows['id']; ?></span></td>
<td width="95" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style23"><?php echo $rows['article_name']; ?></span></td>
<td width="90" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style23"><?php echo $rows['article_image']; ?></span></td>
<td width="119" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style23"><?php echo substr($rows['article_sdesc'],0,25); ?></span></td>
<td width="120" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style23"><?php echo substr($rows['article_desc'],0,25); ?></span></td>
<td width="72" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style23"><?php echo $rows['article_date']; ?></span></td>
<td width="93" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style23"><?php echo $rows['article_url']; ?></span></td>
<td width="56" align="center" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style24 style24"><a href="guncelle.php?id=<?php echo $rows['id']; ?>">Güncelle</a></span></td>
<td width="28" align="center" nowrap bordercolor="#FF0000" bgcolor="#000000"><span class="style24 style24"><a href="sil.php?id=<?php echo $rows['id']; ?>">Sil</a></span></td>
<td width="55" align="center" nowrap bordercolor="#FF0000" bgcolor="#000000"><?php if($rows['article_stat']=="1"){echo "Aktif" ;} elseif($rows['article_stat']=="0"){echo "Pasif";} ?></td>
</tr>
<?php
}
?>
</table>
<br><br>
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'] ; ?>">
<table width="924" height="68" border="0" cellpadding="2" cellspacing="2" bordercolor="#FFFFFF" bgcolor="#FF0000">
<td height="16" colspan="7" valign="middle" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><span class="style22">Makale Ekle</span></td>
</tr>
<tr>
<td width="147" height="16" valign="middle" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><strong>Makale Ad?</strong></td>
<td width="68" valign="middle" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><strong>Makale Resmi</strong></td>
<td width="144" valign="middle" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><strong>Makale K?sa Aç?klama</strong></td>
<td width="144" valign="middle" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><strong>Makale Aç?klama</strong></td>
<td width="144" valign="middle" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><strong>Makale Tarihi</strong></td>
<td width="145" valign="middle" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><span class="style15"><strong>Harici Ba?lant?</strong></span></td>
<td width="88" valign="middle" nowrap bordercolor="#FFFFFF" bgcolor="#000000">Ekle</td>
</tr>
<tr>
<td width="147" height="28" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><input name="article_name" type="text" id="article_name" >
</td>
<td width="68" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><select name="article_image" id="article_image" ><?php
$dirpath = "resim";
$dh = opendir($dirpath);
while (false !== ($file = readdir($dh))) {
//Don't list subdirectories
if (!is_dir("$dirpath/$file")) {
//Truncate the file extension and capitalize the first letter
echo "<option value='$file'>" . htmlspecialchars(ucfirst(preg_replace('/\..*$/', '', $file))) . '</option>';
}
}
closedir($dh);
?></select></td>
<td width="144" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><textarea name="article_sdesc" id="article_sdesc"></textarea></td>
<td width="144" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><textarea name="article_desc" id="article_desc"></textarea></td>
<td width="144" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><input name="article_date" type="text" id="article_date" value="<?php echo date("d-m-y"); ?>"></td>
<td width="145" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><input name="article_url" type="text" id="article_url" ></td>
<td width="88" align="center" valign="middle" nowrap bordercolor="#FFFFFF" bgcolor="#000000"><input type="submit" name="Submit" value="Ekle"></td>
</tr>
</form>
</table>
<br>
<?php
$articlename=$_POST['article_name'];
$articleimage=$_POST['article_image'];
$articlesdesc=$_POST['article_sdesc'];
$articledesc=$_POST['article_desc'];
$articledate=$_POST['article_date'];
$articleurl=$_POST['article_url'];
if($articlename == false || $articleimage == false || $articlesdesc == false || $articledesc == false || $articledate == false || $articleurl == false){
echo "Gerekli alanlar? doldurunuz !";
}else{
// Insert data into mysql
$sql2="INSERT INTO $tbl_name(article_name, article_image, article_sdesc, article_desc, article_date, article_url)VALUES('$articlename', '$articleimage', '$articlesdesc', '$articledesc', '$articledate', '$articleurl')";
$result2=mysql_query($sql2);
echo "Tebrikler ! Yeni bir makale eklediniz...." ;
exit();
}
?>
</body>