Dear Sir,
I have following codes
<?php
$country="";
$capital="";
if (isset($_POST['submit'])){
$country=$_POST['text1'];
$capital=$_POST['text2'];
if (empty($country) || empty($capital)){
die ("<script> alert('Please fill both boxes')</script>");
}else{
echo "<script> alert('The capital of $country is $capital')</script>";
}
if (isset($_POST['clear'])){
$country="";
$capital="";
}
}
?>
<html>
<head>
<title>Result on same page</title>
</head>
<body>
<center>
<form name="form1" action="" method="post">
Country<input type="text" name="text1" value="<?php echo $country;?>"><br>
Capital<input type="text" name="text2" value="<?php echo $capital;?>"> <br><br>
<input type="submit" name="submit" value="Result">
<input type="submit" name="clear" value="clear">
</form>
</center>
</body>
</html>
When I enter values in boxes and press Display Button then it shows result on same page
But...
When When I press Display Button without entring any values in textboxes then browser goes to second page.
With empty boxes it show result on next page.
I want it to remain in same brower in both case, Filled textbox or Empty texbexes.
Please help