I am making a simple mobile application that sends an email to the user with their GPS location and other form input. I am not worried about the validation now I just want to get the form sent to email, although help with that would be appreciated.
Process.php and especially the confirmation is the main problem. I do not know how to correctly put the GPS coordinates into the confirmation email nor display the form/email sent verification to the user on successful submission. I do not know how to select the text input of the GPS Lat and Longitude. Syntax is also obviously incorrect.
<head>
<meta content="text/html; charset=windows-1252" http-equiv="content-type">
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css">
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
</head>
<body>
<div data-role="page" id="page">
<div data-role="header">
<h1>Hitch Fox -Travel with smarts</h1>
</div>
<div data-role="content"> * = required
<form id="myform" action="process.php" method="POST">
<div data-role="fieldcontain"> <label for="email"><em> * </em>
Email:</label> <input name="email" id="verify email" value="" required="required"
type="email"> </div>
<div data-role="fieldcontain"> <label for="verify email"><em> * </em>
Verify Email: </label> <input name="verify email" id="verify email"
value="" required="required" type="email"> </div>
<br>
<div data-role="fieldcontain"> <label for="GPS Latitude"><em> * </em>
GPS Lat </label> <input name="GPS Lat" id="GPSlat" value="" type="text">
</div>
<br>
<div data-role="fieldcontain"> <label for="GPS Longitude"><em> * </em>
GPS Long </label> <input name="GPS Long" id="GPSlong" value="" type="text">
</div>
<br>
<button id="SetGPS"> Set GPS</button>
<div data-role="fieldcontain"><label for="License Plate"><em> * </em>License
Plate: </label> <input name="License Plate" id="LicensePlate" value=""
required="true" type="text"> </div>
</form>
<button id="submit">Submit</button>
<div dat-role="fieldcontain"id="ack"></div> //confirmation of form sent to email goes here
<!--/fieldcontain-->
<div data-role="footer">
<h4>footer</h4>
</div>
<!--/content-->
</div>
<!--/page-->
<script type="text/javascript">
var lat, lng;
navigator.geolocation.getCurrentPosition(function(position)
{
lat = position.coords.latitude;
lng = position.coords.longitude;
console.log( lat + ":" + lng);
});
// ...
$("#SetGPS").click(function()
{
$("input#GPSlat").val(lat);
$("input#GPSlong").val(lng);
});
</script>
<script type="text/javascript">
$("submit").click(function() {
.post( $("myForm").attr("action"),
$("myForm" :input").serializeArray(),
function(info) {
$("#ack").empty();
$("#ack").html(info);
clear();
});
$("#myForm").submit( function () {
return false;
});
});
function clear() {
$("myForm :input").each ( function() {
$(this).val("");
});
)
</script>
<?php
$Email = $ _POST['Email'];
$GPS Lat = $ _POST['GPS Lat'];
$GPS Long = $ _POST['GPS Long'];
$License Plate = $ _POST['License Plate'];
$to = "$Email"
$from = "$Email"
$subject = "Your last GPS Location"
$body = "Your last GPS location was - latitude:" .$GPS Lat " " "longitude:" .$GPS Long "and you were picked up by vehicle license:" .$License Plate // problems here
mail ($to, $from, $subject, $body)
echo $ack "message sent" // php syntax is wrong no doubt
?>