Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I'm trying to set up a form that will allow visitors to my web page to text message me on my cell phone. I've basically modified an email contact form for this purpose (the email contact form was written in PHP). Part of the original email contact form included error checking for things like making sure all fields were filled out, you weren't sending too many messages in too little time, you filled out a code displayed to make sure you weren't a bot, etc. I'd like to include a new error check to make sure the message entered doesn't exceed 135 characters. Below are the codes for all the error checks as well as the HTML that makes up the textarea field. If anyone could help me out, it'd be greatly appreciated! Thanks.Code: Select all
//----- Start Error Checking -----\\
//check to see if fields already been checked
if ($_POST['previewdone'] != "1") {
//check if all fields filled in (except phone field)
if (!$_POST['userMessage']){
$message[$p] = "<font color=red>All required fields not filled in</font>";
$p++;
get_values(1,0);
$notcomplete = "1";
}
//check if email is in valid format
if(check_email($_POST['userEmail']) == "0" && $_POST['userEmail']){
$message[$p] = "<font color=red>Invalid e-mail address</font>";
$p++;
get_values(1,0);
}
//check if security code is correct
if($_POST['userSecurityCode'] != base64_decode($_POST['SecurityCode']) && $usesecuritycode == "true" && $notcomplete != "1"){
$message[$p] = "<font color=red>Wrong security code</font>";
$p++;
get_values(1,0);
}
//check that x seconds has passed
if($submittime > $allowedtime && $usetimelimit == "true"){
$message[$p] = "<font color=red>You are trying to send messages too often. Please try again after ".$timeleft." seconds.</font>";
$p++;
get_values(1,0);
}
}
//----- End Error Checking -----\\
<tr>
<!-- Start Message Field-->
<td colspan="2">Message: <font size=1 color=red>(required)</font>
<br />
<textarea name="userMessage" rows="14" cols="76"><?php echo $userMessage; ?></textarea></td>
<!-- End Message Field-->
</tr>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]