Friday, 30 August 2019

data inserted in another page


Some changes in form.php presented by
different color
<html>
<head>
<link rel="stylesheet"  href="admission.css">
</head>
<body>

<p id="place"></p>
<script>
var x = document.getElementById("place");

function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
  } else {
    x.innerHTML = "Geolocation is not supported by this browser.";
  }
}

function showPosition(position) {
  x.innerHTML = "Latitude: " + position.coords.latitude +
  "<br>Longitude: " + position.coords.longitude;
}
</script>
<form  method="POST" action="form inserted.php"  >
<table frame="box" align="center">
<tr><td>Name</td><td><input type ="text" name="n1"></td></tr>
<tr><td>F_Name</td><td><input type ="text" name="f1"></td></tr>
<tr><td>Class</td><td><select name="cla">
<option>8th</option>
<option>9th</option>
<option>10th</option>
</select>

</td></tr>
<tr><td>Gender</td></tr>
<tr><td><input type="radio" name="g1"value="male">Male</td></tr>
<tr><td><input type="radio" name="g1" value="female">Female</td></tr>
<tr><td>Cources:</td></tr>
<tr><td ><input type="checkbox" name="c1[]"  id="c1" value="Cricket">Cricket</td></tr>
<tr><td ><input type="checkbox" name="c1[]"   id="c1" value="Football">Football</td></tr>
<tr><td>Latitued</td><td><input type="text"></td><td>Longitude</td><td><input type="text"></td></tr>


<tr><td><button onclick="getLocation()">get Location</button></td></tr>


<tr><td><input type="submit" name="submit"></td></tr>

</table>
</form  >
<p id="place"></p>
</body>
</html>
Form inserted.php
<?php
if (isset($_POST['submit']))
{
$name=$_POST['n1'];
$fname=$_POST['f1'];
$gen=$_POST['g1'];
$class=$_POST['cla'];

echo $name."<br>";
echo $fname."<br>";
echo $class."<br>";
echo $gen."<br>";
if(!empty($_POST['c1'])){
foreach($_POST['c1'] as $selected){
echo $selected."</br>";
}
}

}

?>


No comments:

Post a Comment