NickG21 Posted January 2, 2007 Share Posted January 2, 2007 hey everyone, i am using formmail.php in order to process one of my web forms and send everything out VIA e-mail. i was wonderig if it was possible to do form validation on the page before it is passed through. i have coding to verify the e-mail address is a valid domain with fsockopen, also just form fields containing only letters or numbers. can i pass the values through these functions before they are sent to formmail.php? thanks in advance Link to comment https://forums.phpfreaks.com/topic/32611-solved-validation-with-formmail/ Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 Of course its possible. Link to comment https://forums.phpfreaks.com/topic/32611-solved-validation-with-formmail/#findComment-151702 Share on other sites More sharing options...
NickG21 Posted January 2, 2007 Author Share Posted January 2, 2007 thanks thorpe, i kind of figured it was possible, i probably should have said does anyone have a general direction they can begin pointing me in to figure out how to accomplish this? :) thanks for the post though Link to comment https://forums.phpfreaks.com/topic/32611-solved-validation-with-formmail/#findComment-151703 Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 You could start by posting the relevent code. Link to comment https://forums.phpfreaks.com/topic/32611-solved-validation-with-formmail/#findComment-151704 Share on other sites More sharing options...
NickG21 Posted January 2, 2007 Author Share Posted January 2, 2007 alright, here is the general php validation i am trying to execute before the information is passed into formmail and below is just a small bit of the html code.[code]<?phpfunction checkEmail($email) { if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) { return FALSE; } list($Username, $Domain) = split("@",$email); if(getmxrr($Domain, $MXHost)) { return TRUE; } else { if(@fsockopen($Domain, 25, $errno, $errstr, 15)) { return TRUE; } else { return FALSE; } }}if (isset($_POST['submit'])) { $company = $_POST['CompanyName']; $name = $_POST['YourName']; $email = $_POST['YourEmailAddress']; $domainName = $_POST['ListOrDomainName']; $username = $_POST['Username']; $password = $_POST['Password']; $credit = $_POST['CreditCardNumber']; $error1 = ''; $error = array(); if (empty($company)) { $error[] = "Comapny"; }if (empty($name)) { $error[] = "Your Name"; }elseif (!preg_match("/^([a-zA-Z])+/",$name)) { $error[] = "Your Name"; $name=""; }if(checkEmail($email) == FALSE) { $error[]="E-Mail Address"; $email = "";} if(empty($username)) { $error[] = "User Name"; }if(empty($password)){ $error[]="Password"; $password.class = "errortext"; }elseif (strlen($password) < 6) { $error[]= "Password Must Contain At Least Six Characters";}if(empty($credit)){ $error[]="Credit Card Number"; } elseif(!preg_match("/^([0-9])+/",$credit)) { $error[] = "Invalid Credit Card Number"; }if(count($error) > 0) { echo "<big><b>The Following Errors Were Found, Please Re-Enter:</b></big><br/>". implode('<br/>', $error). "</p>"; } else { header('Location: ./Thanks.php'); exit; }}?>[/code][code]<table class="qForm"> <tr> <td colspan="2" class="header">Contact Information</td> </tr> <tr> <td class="left"><a><span class="<?print $text?>">Company Name:</td> <td><input name="CompanyName" size="28" value="<?echo "$company"?>"></td> </tr> <tr> <td class="left">Your Name :</td> <td><input name="realname" size="28" value="<?echo "$name"?>"></td> </tr> <tr> <td class="left">Your Email Address:</td> <td><input name="email" size="28" value="<?echo "$email"?>"></td> </tr><input type="hidden" name="Subject" value="Cancellation Form" /> <input type="hidden" name="required" value="realname, email, ListorDomainName" /> <input type="hidden" name="recipients" value="[email protected]" /> <td style="padding: 1.5em 0; text-align: center;"> <input type="submit" name="submit" value="Submit" /> <input type="reset" value="Reset" />[/code] Link to comment https://forums.phpfreaks.com/topic/32611-solved-validation-with-formmail/#findComment-151710 Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 Sorry, Im a little lost. Is formail something Im meant to know about? Link to comment https://forums.phpfreaks.com/topic/32611-solved-validation-with-formmail/#findComment-151714 Share on other sites More sharing options...
NickG21 Posted January 2, 2007 Author Share Posted January 2, 2007 formmail.php is just a general mailing script that is used by a lot of people to easily send e-mails with form data from websites. sorry, i thought it was more well known than that. anyway, i figured out my problem, sorry to waste your time Link to comment https://forums.phpfreaks.com/topic/32611-solved-validation-with-formmail/#findComment-151716 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.