所以我需要将我创建的 HTML 调查转换为 PHP 表单。我对此非常迷茫。它需要测试我没有的正则表达式,但如果有人可以使用我必须帮助我创建一些很棒的信息。我确定我所有的标签都可以有一个正则表达式,但我不确定如何准确地做到这一点。我还需要验证表格。有人可以帮忙吗?
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>third html page</title>
<link rel="stylesheet" type="text/css" href="mycss.css" />
</head>
<body style="background-color: #7C7D5E">
<form name="survey" method="post" action="http://webdev.spsu.edu/formtest.php">
<div style="background-color: #7C7D5E; text-align: center">
<header>
<a href="http://www.spsu.edu">
<img src="http://www.spsu.edu/_resources/home2012/images/spsulogo.png" alt="SPSU LOGO" style="float: right;" />
</a><font size="6" color="#7D0541"><strong>CSE Center for Health Information Technology</strong></font>
<br />
<font size="1" color="black"> sponsored by <a href="http://cse.spsu.edu" style="text-decoration: none">the CSE Department</a></font>
</header>
<br />
</div>
<script type="text/javascript">
function navigate() {
window.open(document.getElementById("links").value);
}
function clickOn(source) {
alert("You clicked on " + source + " and the id is " + source.id);
}
</script>
<div id="menu" style="background-color: #AFB090; text-align: center">
<table width="50%" border="0">
<tr>
<td>
<select id="links" onchange="navigate()">
<option value="">Quick Links</option>
<option value="HOMEPAGE.HTML">HOME</option>
<option value="FACULTY.HTML">FACULTY</option>
<option value="SURVEY.HTML">SURVEY</option>
<option value="summer_job.HTML">INTERNSHIP</option>
</select>
</td>
<td align="CENTER"><a href="HOMEPAGE.HTML" style="TEXT-DECORATION: NONE">HOME</a></td>
<td align="CENTER"><a href="FACULTY.HTML" style="TEXT-DECORATION: NONE">FACULTY</a></td>
<td align="CENTER"><a href="SURVEY.HTML" style="TEXT-DECORATION: NONE">SURVEY</a></td>
<td align="CENTER"><a href="summer_job.HTML" style="TEXT-DECORATION: NONE">INTERNSHIP</a></td>
</tr>
</table>
</div>
<div id="emaillnk">
<h1><a href="survey.html"><font size="6" face="calibri"><strong>Survey</strong></font></a></h1>
</div>
<br />
<label>
Last Name:
</label>
<input type="text" id="lastname" name="lastname" size="25" />
<br />
<label>
First Name:
</label>
<input type="text" name="firstname"
id="firstname" size="25" />
<br />
<label>
Address:
</label>
<input type="text" name="address"
id="address" size="25"/>
<br />
<label>
City:
</label>
<input type="text" name="city"
id="city" size="25"/>
<br />
<label>
State:
</label>
<select name="state" id="state">
<option value="AL">Alabama</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
</select>
<br />
<label>
Zip Code:
</label>
<input type="number" name="zip"
id="zip" size="7"/>
<br />
<label>
Email:
</label>
<input type="email" name="email"
id="email" size="25" />
<br />
<table>
<tr>
<th>Language Spoken: </th>
<td>
<span>English
<input type="radio" name="pref_lang"
id="pref_lang_en" value="en"
checked="checked" />
</span>
</td>
<td>
<span>Français
<input type="radio" name="pref_lang"
id="pref lang fr" value="fr" />
</span>
</td>
<td>
<span>Español
<input type="radio" name="pref_lang"
id="pref lang es" value="es" />
</span>
</td>
</tr>
</table>
<br />
<label>
Major Selected:
<select name="major" id="major">
<option value="IT">Information Technology</option>
<option value="CS">Computer Science</option>
<option value="SWE">Software Engineering</option>
<option value="PHY">Physics</option>
<option value="BIO">Biology</option>
</select>
</label>
<br />
<table>
<tr>
<th>Term(s) Applying For:
<br />
</th>
</tr>
<tr>
<td>
<span>2013 ONLY
<input name="term[]" type="checkbox" checked="checked" id="PT1" value="true" />
</span>
</td>
<td>
<span>2013 - 2014
<input name="term[]" type="checkbox" name="full semester" id="FT" value="true" /></span>
</td>
</tr>
<tr>
<td>
<span>2014 ONLY
<input name="term[]" type="checkbox" name="spring semester" id="PT2" value="true" />
</span>
</td>
</tr>
</table>
<br />
<input type="button" value="Submit" onclick="Submitsurvey()" />
</form>
<table id="suveryResultsTbl" class="hide">
<tr>
<td>Your Last Name is:
</td>
<td id="LNameRslt"></td>
</tr>
<tr>
<td>Your First Name is:
</td>
<td id="FNameRslt"></td>
</tr>
<tr>
<td>Your Email is:
</td>
<td id="EmailRslt"></td>
</tr>
</table>
<script type="text/javascript">
function Submitsurvey() {
if (!ValidateForm()) {
return false;
}
document.getElementById("survey").submit();
}
function ValidateForm() {
if (document.getElementById('lastname').value.length === 0) {
alert("Last Name Field is Required");
return false;
}
document.getElementById('LNameRslt').value = document.getElementById('lastname').value;
var chkboxesSelected = 0;
if (document.getElementById("PT1").checked === true) {
chkboxesSelected++;
}
if (document.getElementById("FT").checked === true) {
chkboxesSelected++;
}
if (document.getElementById("PT2").checked === true) {
chkboxesSelected++;
}
if (chkboxesSelected === 0) {
alert("At least one MUST be checked");
return false;
}
return true;
}
</script>
</body>
</html>