cdmoody
11-20-2009, 01:09 AM
Hi,
I'm new to PHP and I'm struggling with a project that requires form validation. The requirements are all fields in the form are required, error message should appear if fields are not completed or completed incorrectly. Phone and email should be in proper format. A confirmation page should appear, thanking the visitor and the page will include all information just entered.
Entered data is written to a file and an email is sent to myself and the visitor. The visitor's email should confirm the info and request a reply.
I've searched tons of resources and I have no idea what I'm doing. I've created the form already.
Here's the form:
<form id="contact" name="contact" method="post" class="form">
<p>
<label for="fname">First Name</label>
<input name="fname" type="text" id="fname" size="50" />
</p>
<label for="lname">Last Name</label>
<input name="lname" type="text" id="lname" size="50" />
<p>
<label for="title">Job Title</label>
<input name="title" type="text" id="title" size="50" />
</p>
<p>
<label for="company">Company</label>
<input name="company" type="text" id="company" size="50" />
</p>
<p>
<label for="address">Mailing Address</label>
<input type="text" name="address" id="address" size="50" /> <br />
<input type="text" name="address" id="address" size="50" />
</p>
<p>
<label for="city">City</label>
<input type="text" name="city" id="city" size="25" />
<label for="zip">Zip Code</label>
<input type="text" name="zip" id="zip" size="10" />
<label for="state">State</label>
<input type="text" name="state" id="state" size="2" />
</p>
<p>
<label for="phone">Phone Number</label>
<input type="text" name="phone" id="phone" size="3" />
<input type="text" name="phone" id="phone" size="3" />
<input type="text" name="phone" id="phone" size="4" />
<label for="fax">Fax Number</label>
<input type="text" name="fax" id="fax" size="3" />
<input type="text" name="fax" id="fax" size="3" />
<input type="text" name="fax" id="fax" size="4" />
</p>
<p>
<label for="email">Email Address</label>
<input type="text" name="email" id="email" size="50" />
<p> Enter any additional comments: <br />
<textarea name="comment" cols="40" rows="5"></textarea>
</p>
<p>
<input type="submit" name="submit" value="Submit"/>
<input name="reset" type="reset" value="Reset" />
</p>
</form>
I'm new to PHP and I'm struggling with a project that requires form validation. The requirements are all fields in the form are required, error message should appear if fields are not completed or completed incorrectly. Phone and email should be in proper format. A confirmation page should appear, thanking the visitor and the page will include all information just entered.
Entered data is written to a file and an email is sent to myself and the visitor. The visitor's email should confirm the info and request a reply.
I've searched tons of resources and I have no idea what I'm doing. I've created the form already.
Here's the form:
<form id="contact" name="contact" method="post" class="form">
<p>
<label for="fname">First Name</label>
<input name="fname" type="text" id="fname" size="50" />
</p>
<label for="lname">Last Name</label>
<input name="lname" type="text" id="lname" size="50" />
<p>
<label for="title">Job Title</label>
<input name="title" type="text" id="title" size="50" />
</p>
<p>
<label for="company">Company</label>
<input name="company" type="text" id="company" size="50" />
</p>
<p>
<label for="address">Mailing Address</label>
<input type="text" name="address" id="address" size="50" /> <br />
<input type="text" name="address" id="address" size="50" />
</p>
<p>
<label for="city">City</label>
<input type="text" name="city" id="city" size="25" />
<label for="zip">Zip Code</label>
<input type="text" name="zip" id="zip" size="10" />
<label for="state">State</label>
<input type="text" name="state" id="state" size="2" />
</p>
<p>
<label for="phone">Phone Number</label>
<input type="text" name="phone" id="phone" size="3" />
<input type="text" name="phone" id="phone" size="3" />
<input type="text" name="phone" id="phone" size="4" />
<label for="fax">Fax Number</label>
<input type="text" name="fax" id="fax" size="3" />
<input type="text" name="fax" id="fax" size="3" />
<input type="text" name="fax" id="fax" size="4" />
</p>
<p>
<label for="email">Email Address</label>
<input type="text" name="email" id="email" size="50" />
<p> Enter any additional comments: <br />
<textarea name="comment" cols="40" rows="5"></textarea>
</p>
<p>
<input type="submit" name="submit" value="Submit"/>
<input name="reset" type="reset" value="Reset" />
</p>
</form>