I have like a contact us form, and basically what I want is for the user to click the submit button and then for this data to be stored on a remote database on a server. Problem is I don't know how to link the javascript
and php
stuff to the button.
This is my code:
<html>
<head>
<title>Contact Us</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</head>
<body>
<script type="text/javascript">
function verify(){
var forename = document.getElementById("forename").value;
var surname = document.getElementById("surname").value;
var comments = document.getElementById("comments").value;
if(forename == null || forename == ""){
alert("Forename is empty");
return false;
}
else if(surname == null || surname == ""){
alert("Surname is empty");
return false;
}
else if(comments == null || comments == ""){
alert("Comments is empty");
return false;
}
document.register.submit();
}
</script>
<div class="container">
<h1>Contact Us</h1>
</div>
<form>
<div class="container center_div">
<div class="panel panel-default">
<div class="row">
<fieldset class="form-group">
<label for="Forename">Forename</label>
<input type="text" class="form-control" id="forename" placeholder="Forename">
</fieldset>
<fieldset class="form-group">
<label for="Surname">Surname</label>
<input type="text" class="form-control" id="surname" placeholder="Surname">
</fieldset>
<fieldset class="form-group">
<label for="Contact Us">Contact Us</label>
<input type="text" class="form-control" id="comments" placeholder="Comments">
</fieldset>
<div class="row">
<div class"col-md-2">
<button type="button" action="contactus.php" class="btn btn-success">Submit</button>
</div>
</div>
</div>
</div>
</form>
</body>
</html>