Skip to content

Instantly share code, notes, and snippets.

@omatt
Last active December 23, 2015 16:09
Show Gist options
  • Save omatt/6660718 to your computer and use it in GitHub Desktop.
Save omatt/6660718 to your computer and use it in GitHub Desktop.
Sample PHP code that accepts input and redirecting to another page.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<title>Seatwork</title>
<script type="text/javascript">
function valForm(){
if(document.myForm.firstName.value==""){
if(document.myForm.firstName.value==""){
document.getElementById("fName").innerHTML = "this is required";
}
else{
document.getElementById("fName").innerHTML = "";
}
}
else{
document.getElementById("fName").innerHTML = "";
}
}
</script>
</head>
<body>
<p>Fill up the following
<hr>
<form name="myForm" action ="output.html" method="post" onsubmit="return valForm()"/>
<p>First name:
<input type="text" name="firstName"/>
<span id="fName" style="color:red"></span>
<p>
<input type = "submit" value="Submit" onclick="valForm()"/>
</form>
</body>
</ html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment