e1$ki
07-31-2008, 06:19 AM
Hi People,
I am not a veteran coder so this may be really obvious when I post that I can't get this to work. The page is at http://www.ewanski-gbc.com/contact2.php
and here is my code:
<?php include 'head1.php'; ?>
<title>Ewanski Green Building Consulting - Contact Us</title>
<script type="text/javascript">
<!--
function validate_form ( )
{
valid = true;
if(document.theform.fullname.value == ""){
alert ( "Please fill in your full name." );
valid = false;
}
if(document.theform.email.value == ""){
alert ( "Please fill in your email address." );
valid = false;
}
if(Verify_Email_Address(document.theform.email.value)){
alert ( "Please enter a valid email address.");
valid = false;
}
if(document.theform.message.value == ""){
alert ( "Please fill in a message." );
valid = false;
}
return valid;
}
function Verify_Email_Address($email_address)
{
//Assumes that valid email addresses consist of user_name@domain.tld
$at = strrpos($email_address, "@");
$dot = strrpos($email_address, ".");
alert ("at = " . $at);
if($at == false ||
$dot == false ||
$dot <= $at + 1 ||
$dot == 0 ||
$dot == strlen($email_address) - 1)
return(false);
$user_name = substr($email_address, 0, $at);
$domain_name = substr($email_address, $at + 1, strlen($email_address));
if(Validate_String($user_name) === false ||
Validate_String($domain_name) === false)
return(false);
return(true);
}
//-->
</script>
<?php include 'head2.php'; ?>
<div id="page">
<div id="content">
<div>
<h2 class="title">Contact Us</h2>
<p>If you have questions, feedback, or an interest in our services, please don't hesitate to contact us. We would love to hear from you!</p>
<p>Please contact us using the online web form below.</p>
<form method="post" action="formtoemail.php" name="theform" onsubmit="return validate_form ( );">
<table border="0" width="100%">
<tr>
<td>Full Name:</td>
<td><input type="text" name="fullname" size="40" maxlength=""></td>
</tr>
<tr>
<td>Email Address:</td>
<td><input type="text" name="email" size="40" maxlength=""></td>
</tr>
<tr>
<td>How We May Help You:</td>
<td><textarea name="message" rows="10" cols="50"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Send">
<input type="reset" value="Clear"></td>
</table>
</form>
</div>
</div>
<?php include 'footer.php'; ?>
I am confused. I just want it to validate that there is a real email in there. I checked the javascript console in Firefox and it said that strrpos wasn't valid but I looked it up at php.net and it's in there. So, I don't know where to look next.
Thanks in advance,
Patricia
I am not a veteran coder so this may be really obvious when I post that I can't get this to work. The page is at http://www.ewanski-gbc.com/contact2.php
and here is my code:
<?php include 'head1.php'; ?>
<title>Ewanski Green Building Consulting - Contact Us</title>
<script type="text/javascript">
<!--
function validate_form ( )
{
valid = true;
if(document.theform.fullname.value == ""){
alert ( "Please fill in your full name." );
valid = false;
}
if(document.theform.email.value == ""){
alert ( "Please fill in your email address." );
valid = false;
}
if(Verify_Email_Address(document.theform.email.value)){
alert ( "Please enter a valid email address.");
valid = false;
}
if(document.theform.message.value == ""){
alert ( "Please fill in a message." );
valid = false;
}
return valid;
}
function Verify_Email_Address($email_address)
{
//Assumes that valid email addresses consist of user_name@domain.tld
$at = strrpos($email_address, "@");
$dot = strrpos($email_address, ".");
alert ("at = " . $at);
if($at == false ||
$dot == false ||
$dot <= $at + 1 ||
$dot == 0 ||
$dot == strlen($email_address) - 1)
return(false);
$user_name = substr($email_address, 0, $at);
$domain_name = substr($email_address, $at + 1, strlen($email_address));
if(Validate_String($user_name) === false ||
Validate_String($domain_name) === false)
return(false);
return(true);
}
//-->
</script>
<?php include 'head2.php'; ?>
<div id="page">
<div id="content">
<div>
<h2 class="title">Contact Us</h2>
<p>If you have questions, feedback, or an interest in our services, please don't hesitate to contact us. We would love to hear from you!</p>
<p>Please contact us using the online web form below.</p>
<form method="post" action="formtoemail.php" name="theform" onsubmit="return validate_form ( );">
<table border="0" width="100%">
<tr>
<td>Full Name:</td>
<td><input type="text" name="fullname" size="40" maxlength=""></td>
</tr>
<tr>
<td>Email Address:</td>
<td><input type="text" name="email" size="40" maxlength=""></td>
</tr>
<tr>
<td>How We May Help You:</td>
<td><textarea name="message" rows="10" cols="50"></textarea></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Send">
<input type="reset" value="Clear"></td>
</table>
</form>
</div>
</div>
<?php include 'footer.php'; ?>
I am confused. I just want it to validate that there is a real email in there. I checked the javascript console in Firefox and it said that strrpos wasn't valid but I looked it up at php.net and it's in there. So, I don't know where to look next.
Thanks in advance,
Patricia