Forum Moderators: coopster

Message Too Old, No Replies

HTML Form using PHP Action Question

         

LDearman

4:49 pm on Jan 22, 2008 (gmt 0)

10+ Year Member



I am trying to get a form to validate a check box that if checked the user must enter in an email address. Below is the form code. If the last check box is checked I need users to enter a vaild email address.

<form name="cac" method="post" action="http://www.example.com/contact_forms/cac.php">
<p><strong>Email:</strong><br />
<input name="Email" type="text" size="50" />
</p>
<p>
<input type="checkbox" name="Contact_me_asap" value="Yes" />
<strong> Please contact me regarding this matter.</strong> </p>
<p>
<input type="button" name="submit" value="Submit" onclick="contactselected()" />
<label>
<input type="reset" name="Reset" value="Reset" />
</label>
</p>
</form>

[edited by: tedster at 6:12 pm (utc) on Jan. 22, 2008]
[edited by: coopster on Jan. 22, 2008 -- clipped irrelevant code]

[edited by: coopster at 6:50 pm (utc) on Jan. 22, 2008]
[edit reason] please use example.com in code [/edit]

coopster

6:54 pm on Jan 22, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com], LDearman.

You are using POST as your form method so you would want to check the existence of the input name in your $_POST superglobal array [php.net].

if (isset [php.net]($_POST['Contact_me_asap'])) { 
// validate email address
}