Hi ,this is my code,see the bold letter that highlighted in this following program....If i am not redirecting this page to another page means ,i am facing big problem like for every refreshment on the browser a dummy data is get inerting into the table(last inserted values into table).to avoid this ,i am calling this same page
header('Location: newentry.php');because i need this same page only and at the same time message to be displayed at the top.

but at the same time "I need message to be displayed like DATA HAS BEEN SAVED SUCCESSFULLY".please help me a idea

<?php


session_start();
if(!isset($_SESSION))
{
header("Location:index.php");
}


mysql_connect("localhost", "root", "")or die("cannot connect");
mysql_select_db("artedb")or die("cannot select DB");



if (isset($_POST) && ($_POST == "submit"))
{


$dt= date("Ymd");
list($year, $month, $day) = split('[/.-]', $_POST);
$cdate = $year.$month.$day;


if($_POST=="")
{
$msg="";
$msg="Enter the Scholar Name";
}
elseif($_POST=="")
{
$msg="";
$msg="Enter the Programme";
}
elseif($_POST=="")
{
$msg="";
$msg="Enter the Department Title";
}
elseif($_POST=="")
{
$msg="";
$msg="Enter the Thesis Title";
}
elseif($_POST=="")
{
$msg="";
$msg="Enter the Evaluator Name";
}
elseif($_POST=="")
{
$msg="";
$msg="Enter the Evaluator Email ID";
}
elseif($_POST=="")
{
$msg="";
$msg="Select Date for the Report";
}
elseif($_POST=="")
{
$msg="";
$msg="Enter the Frequency";
}
elseif($_POST=="")
{
$msg="";
$msg="Select Date for the Hardcopy";
}


elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST))
{
$msg="";
$msg="Invalid email";
}
elseif($cdate<$dt)
{
$msg="Please select a valid date";
}
elseif(!isset($_SESSION))
{


header("Location:index.php");
}


else
{
$q=mysql_query("select uid from thesies order by uid desc")or die(mysql_error());
$l = mysql_fetch_array($q);


$subd=substr($l,0,8);
$subid=substr($l,-2);//last 2 digit number
$date=date('Ymd');
if($date==$subd)
{
if($subid>="09")
{
$count=(int)$subid+1;
$incre=$date.$count ;
}
else
{
$cc=(int)$subid+1;
$dumm="0";
$count=$dumm.$cc;
$incre=$date.$count ;
}
}
else
{
$count='01';
$incre=$date.$count ;
}


mysql_query("insert into thesies(uid,scholarname,thesiestitle,evaluatorname,evaluatoremail,remidfrom,frequency,lastmail,nextmail,mailcount,programme,department,hardcopy) values('$incre','$_POST[sname]','$_POST[ttitle]','$_POST[ename]','$_POST[email]','$_POST[remind]','$_POST[freq]','','$_POST[remind]','','$_POST[programme]','$_POST[department]','$_POST[hard]')")or die(mysql_error());//$_POST="";
//$msg="Data has been saved successfully....";
//header('Location: msg.php?name=insert');
header('Location: newentry.php');      }
}
?>
<html>
<head>
<title>ARTE</title>
<style type="text/css">
.style1 {font-size: 18px; font-weight: bold; color:25547D; font-family:Verdana;}
.style2 {font-size: 12px; font-weight: bold; color:25547D; font-family:Verdana;}
.style3 {font-size: 11px; font-weight: bold; color:black;  font-family:Verdana;}
.style4 {font-family: Verdana;font-weight: normal;font-size: 11px;color: #404040;background-color: #fafafa;border: 1px #ffffff solid;
border-collapse: collapse;border-spacing: 0px;margin-top: 10px;
}
</style>
</head>
<body>
<table align="center" >
<tr>
<td align="center"><br /><br />
<span class="style1">    Indian Institute of Technology Madras <br /></span>
<span class="style2">    Chennai - 600 036. <br /></span>
</td>
</tr>
</table><br /><br /><br /><br /><br />
<table align="center">
<tr><td><font color="#FF0000"><b><? echo $msg; ?></b></font></td></tr>
</table>
<form method="POST" name="newentry">
<span class="style4">
<table width="60%" border="0" cellpadding="0" cellspacing="5" align="center">
<tr>
<td colspan="3"><span class="style3"><i><b> Please, note that fields marked with <font color="#FF0000">*</font> are mandatory</b></i></span></td>
</tr>
<tr>
<td width="50%"><span class="style3">1.Scholar Name <font color=red>*</font></span></td>
<td><input name="sname" type="text" id="sname" value="<?= $_POST[sname] ?>" size="40" length=50></td>
</tr>
<tr><td></td></tr>
<tr>
<td width="50%"><span class="style3">2.Programme <font color=red>*</font></span></td>
<td><select name="programme" style="width: 275px" value="<?= $_POST[programme] ?>">
<option></option>
<option value="MS">MS</option>
<option value="Ph.D">Ph.D</option></td>
</tr>
<tr><td></td></tr>
<tr>
<td width="50%"><span class="style3">3.Department <font color=red>*</font></span></td>
<td><select name="department" style="width: 275px" value="<?= $_POST[department] ?>">
<option></option>
<option value="Aerospace Engineering">Aerospace Engineering</option>
<option value="Applied Mechanics">Applied Mechanics</option>
<option value="Civil Engineering">Civil Engineering</option>
<option value="Chemical Engineering">Chemical Engineering</option>
<option value="Computer Science and Engg.">Computer Science and Engg.</option>
<option value="Composites Technology Centre">Composites Technology Centre</option>
<option value="Chemistry">Chemistry</option>
<option value="Electrical Engineering">Electrical Engineering</option>
<option value="Humanities and Social Sciences">Humanities and Social Sciences</option>
<option value="Mathematics">Mathematics</option>
<option value="Mechanical Engineering">Mechanical Engineering</option>
<option value="Metallurgical  & Materials Engineering ">Metallurgical and Materials Engineering </option>
<option value="Ocean Engineering">Ocean Engineering</option>
<option value="Physics">Physics</option>
<option value="Bio-Technology">Bio-Technology  </option>
<option value="Management Studies">Management Studies</option>
<option value="Engineering Design ">Engineering Design </option></td>
</tr>
<tr><td></td></tr>
<tr>
<td width="50%"><span class="style3">4.Thesis Title <font color=red>*</font> </span></td>
<td><textarea name="ttitle" id="ttitle" rows=2 cols=32><?= $_POST[ttitle] ?></textarea></td>
</tr>
<tr><td></td></tr>
<tr>
<td width="50%"><span class="style3">5.Evaluator Name <font color=red>*</font> </span></td>
<td><input name="ename" type="text" id="ename" value="<?= $_POST[ename] ?>" size=40 ></td>
</tr>
<tr><td></td></tr>
<tr>
<td width="50%"><span class="style3">6.Email of the Evaluator <font color=red>*</font> </span></td>
<td><input name="email" type="text" id="email" value="<?= $_POST[email] ?>" size=40></td>
</tr>
<tr><td></td></tr>
<tr>
<td width="50%"><span class="style3">7.Reminder For Report(YYYY-MM-DD) <font color=red>*</font> </span></td>
<td><input type="text" name="remind" value="<?= $_POST[remind] ?>" readonly="true">
<IMG id="img1"  style="CURSOR: hand" src="Calendar.gif" align="middle" name="date" Value="Calendar" onClick='javascript:window.open("calendar.php?form=newentry&field=remind","","top=160,left=800,width=175,height=140,menubar=no,toolbar=no,scrollbars=no,resizable=no,status=no"); return false;'></td>
</tr>
<tr><td></td></tr>
<tr>
<td width="50%"><span class="style3">8.Frequency <font color=red>*</font> </span></td>
<td><input name="freq" type="text" value="<?= $_POST[freq] ?>" id="freq" onkeypress="NumericKeyPress(event)" maxlength="2" size="2"><span class="style3"> (no of days)</span></td>
</tr>
<tr><td></td></tr>
<tr>
<td width="50%"><span class="style3">9.Hardcopy Sended Date(YYYY-MM-DD) <font color=red>*</font> </span></td>
<td><input type="text" name="hard" value="<?= $_POST[hard] ?>" readonly="true">
<IMG id="img1"  style="CURSOR: hand" src="Calendar.gif" align="middle" name="date" Value="Calendar" onClick='javascript:window.open("calendar.php?form=newentry&field=hard","","top=160,left=800,width=175,height=140,menubar=no,toolbar=no,scrollbars=no,resizable=no,status=no"); return false;'></td>
</tr>
<tr><td></td></tr>
<tr>
<td align="right">
<input type="submit" name="submit" id="submit" value="submit" />
</td>
<td><input type="reset" name="reset" id="reset" value="Reset" /></td>
</tr>


</table>
</span>
<br/><br/> <br/><br/> <br/><br/> <br/><br/>
<span class="style4">
<table width="40%" border="0" cellpadding="0" cellspacing="5" align="center">
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr>
<td width="50%" align="center">
<span class="style3">
Please click here to go to Search details..<a href="search.php">Search</a>
</span>
</td>
</tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr>
<td width="50%" align="center">
<span class="style3">
Please click here to Log out.....<a href="logout.php" >Log Out</a>


</span>
</td>
</tr>
</table>
</span>
</form>
</body>
</html>

Edited 3 Years Ago by happygeek: fixed formatting

Comments
Use [code] tags.

hi this is nathen,
you just out exit; at the end of i think this is work for you

$_POST="";
$msg="Data has been saved successfully....";
header('Location: msg.php?name=insert');
exit;

This article has been dead for over six months. Start a new discussion instead.