PHP - Email Validation Within A Function
Hello i have a syntax issue in the code below, can anyone shed some light?
Code: [Select] <?php if(isset($_POST['submit'])) { $drop = mysql_real_escape_string($_POST['drop_1']); $tier_two = mysql_real_escape_string($_POST['Subtype']); echo "You selected "; echo $drop." & ".$tier_two; $Name = mysql_real_escape_string($_POST["Name"]); $Phone = mysql_real_escape_string($_POST["Phone"]); $Email = mysql_real_escape_string($_POST["Email"]); $Postcode = mysql_real_escape_string($_POST["Postcode"]); $Website = mysql_real_escape_string($_POST["Website"]); if($Name == '' || $Phone == '' || $Email == '' else if (!preg_match('/^[A-Za-z0-9\-.]+$/', $domain)|| $Postcode == '' || $Website == '') { die('<br> but you did not complete all of the required fields correctly, please try again'); } } the code works fine without the " else if (!preg_match('/^[A-Za-z0-9\-.]+$/', $domain) " . As well as checking for blank fields i'd like to check for the correct email format. Many thanks. Similar TutorialsEverything about the email is sending except the message text does anyone know what the issue could be? here is the block of code that sends the email Thanks in advance Code: [Select] $image = "http://www.visualrealityink.com/dev/clients/arzan/snell_form/images/email.png"; echo "got to process form"; $target_path = "upload/"; $path = $target_path = $target_path . basename( $_FILES['file']['name']); $boundary = '-----=' . md5( uniqid ( rand() ) ); $message .= "Content-Type: application/msword; name=\"my attachment\"\n"; $message .= "Content-Transfer-Encoding: base64\n"; $message .= "Content-Disposition: attachment; filename=\"$path\"\n\n"; echo $path; $fp = fopen($path, 'r'); do //we loop until there is no data left { $data = fread($fp, 8192); if (strlen($data) == 0) break; $content .= $data; } while (true); $content_encode = chunk_split(base64_encode($content)); $message .= $content_encode . "\n"; $message .= "--" . $boundary . "\n"; $message .= $image . "<br />" . $_POST['name'] . "submitted a resume on our website. Please review the applications and contact the candidate if their resume is a fit for any open opportunities with the company. <br><br> Thank you. <br><br> SEI Team"; $headers = "From: \"Me\"<me@example.com>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\""; mail('george@visualrealityink.com', 'Email with attachment from PHP', $headers, $message); Hello all, I used simple php email function but it send an email in junk folder or spam. Can anyone tell me why is this so? Her is the code: $host = "ssl://smtp.gmail.com"; $port = "465"; $to = " xx@gmail.com"; // note the comma $subject = " $_POST[company_website] "; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: About Wholesale Account' . "<$_POST[email]>\r\n"; $headers .= 'Cc: mail@gmail.com' . "\r\n"; $headers .= 'Bcc: cc@gmail.com' . "\r\n"; mail($to, $subject, $message, $headers); Hello Guys,
I need your help as many PHPers here is more experienced in PHP coding than me. I have specific project I am working on and need a piece of code that can send an email from HTML form using PHP to the email address that is entered manually on the form, instead of standard sent to PHP code that is fixed within PHP script and executed during submission. I want sth that can grab manually enetered recipient's e-mail address, paste it to the PHP code and then use it to send the email to the recipient, instead of fixed sent to code. Something would say dynamically changed during the entry that can inject into PHP code the new address email entered on the form and then submit to it. Any ideas will be great.
Thanks.
Edited March 27, 2019 by slawotrend Hey guys.. I'm completely done with my contact form data validation except I cannot seem to get one part. For my email field I need to make sure that it is a valid email address and not just words. Also, I would like to make the phone number specific length. Any ideas on how to go about this? thanks guys! <?php ini_set('display_errors', '0'); //Define Variables. $FirstName = $_GET['FirstNameTextBox']; $LastName = $_GET['LastNameTextBox']; $PhoneNumber = $_GET['PhoneNumberTextBox']; $EmailAddress = $_GET['EmailAddressTextBox']; $Address = $_GET['AddressTextBox']; $City = $_GET['CityTextBox']; $State = $_GET['StateDropDownBox']; $Zip = $_GET['ZipTextBox']; $error1='*Please enter a First Name<br>'; $error2='*Please enter a Last Name<br>'; $error3='*Please enter a Phone Number<br>'; $error4='*Please choose a state<br>'; $error5='*Please enter a valid email address<br>'; $day2 = mktime(0,0,0,date("m"),date("d")+2,date("Y")); $day3 = mktime(0,0,0,date("m"),date("d")+3,date("Y")); $day7 = mktime(0,0,0,date("m"),date("d")+7,date("Y")); // Array to collect messages $messages = array(); //Display errors. if($FirstName=="") {$messages[] = $error1; } if($LastName=="") {$messages[] = $error2; } if($PhoneNumber=="") {$messages[] = $error3; } if($State=="") {$messages[] = $error4; } if($EmailAddress=="") {$messages[] = $error5; } // Don't do this part unless we have no errors if (empty($messages)) { //Display correct contact date. if($State == "NY") { $messages[] = "Hello $FirstName $LastName! Thank you for contacting me. I will get back to you within 2 days, before " .date("d M Y", $day2); } if($State == "NJ") { $messages[] = "$Hello FirstName $LastName! Thank you for contacting me. I will get back to you within 3 days, before " .date("d M Y", $day3); } if($State == "Other") { $messages[] = "$Hello FirstName $LastName! Thank you for contacting me. I will get back to you within 1 week, before " .date("d M Y", $day7); } } // END if empty($messages echo implode('<BR>', $messages); ?> <p>--<a href="Contact_Form.html" class="style2"><span class="style1">Go Back</span></a>--</p> </body> </html> So, im trying to make my job a little easier. lol... I am constantly sending emails to the managers for escalations on calls... So I wrote this so far... (forgive my poor php skills, this is the first thing ive ever made. lol.) It does work so far, but, a friend wants to use it too, and Ive adapted it so he can enter his email address in, but, how can I make it so that it will validate only to send from @specificdomain.com ? Ive tried a few things, and just butchered it. lol.... Thanks for any help or tips. Code: [Select] <?php //$name = $_POST["email"]; $name = $_POST["name"]; $policynumber = $_POST["policynumber"]; $phonenumber = $_POST["phonenumber"]; $issue = $_POST["issue"]; $purchased = $_POST ["purchased"]; $infocheck = $_POST ["infocheck"]; $additionalinfo = stripslashes($_POST["additionalinfo"]); //checkbox value readout $mailcc = $_POST['sendmetoo']; $email_to = "SalesLevel2@specificurl.com"; // Who the email is to $email_from = $_POST['emailfrom']; // Who the email is from $email_subject = $policynumber.' - '.$issue; // The Subject of the email //here you can define whatever you want to... $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=UTF-8\r\n"; $headers .= "To: <".$email_to.">\r\n"; $headers .= "From: ".$email_from."\r\n"; //we control if sendmetoo is checked... if($mailcc == 'sendtome'){ $headers .= "Cc: ".$email_from."\r\n"; } //$headers .= "Bcc: noone@nowhere.com\r\n"; $email_message = "Sales Level 2,"; $email_message .= "\n\nPolicy Number: " .$policynumber; $email_message .= "\nClients Name: " .$name; $email_message .= "\nPhone Number: " .$phonenumber; $email_message .= "\nReason(s): " .$issue; $email_message .= "\nPurchased Already: " .$purchased; $email_message .= "\nAll info correct?: " .$infocheck; $email_message .= "\n\nAdditional Information: " .$additionalinfo; "\n\n\n\n". // Message that the email has in it //$headers = "From: ".$email_from; $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { echo "<font face=verdana size=2><center>Your message has been sent<br> to Sales Level 2<br> Click <a href=\"#\" onclick=\"history.back();\">here</a> to go back</center>"; } else { die("Sorry but the email could not be sent. Please go back and try again!"); } ?> Hi, I have done email validation. At present it shows invalid email address if I kept blank but in the same time inserted the records in database. I want user to stay at the same page if anything is invalid. if(!empty($_POST['emailId'])){ if(preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $_POST['emailId'])){ $records['Email']=$_POST['emailId']; } else{ $emsg="Please enter valid Email address"; }} else{ $emsg="Please enter valid Email address"; } And I have used like <tr><td>Email id</td><td><input type="text" name="emailId"></td><td><?php echo ".$emsg." ;?></td></tr> Can anybody help me in this regard? Hey, i'm needing to use email in a php script, but i've had no luck getting this working.. Even with perfectly given details. Is there another way which would let me email? I've tried using smtp details from live, gmail, isp email... All of which say it's send, but is not the case. The function is extremely broken, is there an alternative? Or some way to get this working? Kris. Hi, I need simple function to validate email address format. I have found follwoing function form google. function isemail($email){ return (bool)ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email); } It's working fine with php < 5.2. But when I'm using with PHP 5.3 is says Quote Deprecated: Function ereg() is deprecated in C:\wamp\www\*******\includes\functions.php on line 28 Is any solution to this without error disable? Thanks I am working on user validation through email and I am having some problems with it. I can get it to work but it gives me probloms some times. This is the link that is sent to the users after they sign up Code: [Select] mydomain/confirm.php?id=".$id."&userkey=".$userkey and this is what i have for the confirm page Code: [Select] <?php //connection info $userquery = mysql_query("SELECT * FROM user"); $active=mysql_result($userquery, "active"); $userid=mysql_result($userquery, "id"); $userkey=mysql_result($userquery, "userkey"); if ($active == 1) { printf("This account has already been activated"); echo "<br />"; } elseif($userkey != $posteduserkey){ printf("We are sorry but the data offered does not match data listed, plese contact system admin."); } else{ $query="UPDATE user SET active='1' WHERE id='$id'"; mysql_query($query) or die (mysql_error()); echo "You have activated your account"; ?> <div align="center"><br /><a href="login.php" class="nav">Back to the log in page</a></div> <?php } ?> This is the fun part. I checked that the id and userkey are correct in the link, and they are. I then replaced the & in the link with & it works in gmail but not yahoo email address. I'm not sure where else to look. Thanks in advance Hey all, trying to figure out a logic flaw in this validation script. Basically if I use !preg_match or the preg_match examples (noted below), I do not get the correct results.
My interpretation of preg_match and my current understanding of the logic is noted below (please correct me if I'm wrong).
1. If I use alternate attempt !preg_match, the regex would be compared against the "string" in the $email variable. If the regex expression matches, error will be thrown and script would stop.
2. If I use alternate attempt !preg_match, the condition would be not true and move to else where the string contained within $email variable would be run through the vld function.
3. If I maintain the current script using preg_match, if the string matches the match, the condition would be true and therefore string of $email variable runs through VLD function else cleanup and throw error...
Are my statements above correct in this context? I think I'm pretty close to cracking it but seem to be missing something simple.
The current script is referenced below, forgive me if I've lost the plot. Long hours attempting to understand this language, from what I've seen so far its great.
Thanks in advance,
A
//Alternate attempt
if (!preg_match("/^[^@]+@[^@.]+\.[^@]*\w\w/", $email)) { $error = "Please enter a valid email address"; } else { $email = vld($_POST['email']); } Current code that doens't work: if (empty($_POST['email'])) { $error = "Email is required"; } else { if (strlen($_POST['email']) < 5) { $error = "Email is too short!"; } else { if (strlen($_POST['email']) > 30) { $error = "Email is too long!"; } else { if (preg_match("/[\(\)\<\>\,\;\:\\\"\[\]]/", $email)) { $error = "The email address contains illegal characters"; } else { if (preg_match("/^[^@]+@[^@.]+\.[^@]*\w\w/", $email)) { $email = vld($_POST['email']); } else { $error = "Please enter a valid email address"; } } } } } } Hi guys, Trying to ge this to work: function checkEmail($useremail) { if (!preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $useremail)) { return false; $error = '<div id="blackText"><p>Sorry! Please check your email address and try again!<p><p><a href="forumsSignUp.php">Back</a></p></div>'; } return true; //PASSWORD AND OTHER VALIDATION STUFF, blah blah blah } But its just not. Everything works fine if I remove this though. Can anyone suggest an alternative to email address validation? Thanks! Hey everyone. I hope you can help me getting through this problem, because I have no idea of what else to try. I'm a web designer and sometimes modify Javascript, but my main focus is HTML and CSS, meaning I have no idea how to code in Javascript, but most importantly, how to write something from scratch in PHP. So I designed a form that works pretty well, and integrated a PHP and Javascript script to make it work. This is the form: Code: [Select] <form name="form" id="form" method="post" action="contact.php"> <p>Hello,</p> <p>My name is <input type="text" name="name">, from <input type="text" name="location">, and I'd like to get in touch with you for the following purpose:</p> <p><textarea name="message" rows="10" ></textarea></p> <p>By the way, my email address is <input type="text" name="email" id="email" placeholder="john@doe.com">, and I can prove I'm not a robot because I know the sky is <input type="text" name="code" placeholder="Red, green or blue?">.</p> <p title="Send this message."><input type="submit" id="submit" value="Take care."></p> </form> And this is the script, in an external file called contact.php: Code: [Select] <?php $name = check_input($_REQUEST['name'], "Please enter your name.") ; $location = check_input($_REQUEST['location']) ; $message = check_input($_REQUEST['message'], "Please write a message.") ; $email = check_input($_REQUEST['email'], "Please enter a valid email address.") ; if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) {die("E-mail address not valid");} if (strtolower($_POST['code']) != 'blue') {die('You are definitely a robot.');} $mail_status = mail( "my@email.com", "Hey!", "Hello,\n\n$message\n\nRegards,\n\n$name\n$location", "From: $email $name" ); function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <html> <body> <b>Please correct the following error:</b><br /> <?php echo $myError; ?> </body> </html> <?php exit(); } if ($mail_status) { ?> <script language="javascript" type="text/javascript"> alert('Thank you for the message. I will try to respond as soon as I can.'); window.location = '/about'; </script> <?php } else { ?> <script language="javascript" type="text/javascript"> alert('There was an error. Please try again in a few minutes, or send the message directly to aalejandro@bitsland.com.'); window.location = '/about'; </script> <?php } ?> So what it does is this: if everything's OK, it sends an email with "Hey!" as the subject, "[name]" as the sender, "Hello, [message]. Regards, [name], [location]" as the body, and a popup saying the message was delivered appears. If something fails, it outputs the error in a new address, so the user will have to go back to the form and correct the error. What I actually want to happen is this: if everything's OK, a <p> which was hidden beneath the form appears saying the message was delivered, or, alternatively, make the submit button gray out and confirm the message was delivered. I found a script to make this happen, but with "Please wait...", so the user can't resubmit the form. If there's an error, I'd like another <p> which was hidden to appear with the specific error, so there'd be many <p>'s hidden with different IDs. If possible, I'd also like to change the CSS style of the input field, specifically changing the border color to red, so it'd be a change in class for the particular field. -- So in essence, I want the errors and the success messages to output in the same page as the form (without refresh), and a change of class in the input fields that have an error. Thanks in advance, and please let me know if it'll be possible. Hello guys, I just want to ask if someone can share me codes in php where i can validate the connection of the mail server. I am going to trap this error: Quote Warning: mail() [function.mail]: Failed to connect to mailserver.... Instead of this message showing, I want it to be formal. It will be like this: Quote You cannot connect to you're mail server. Please contact the administrator. And lastly I want to have a validation if an email is existing or not. I want a script which checks first the email if it is existing before sending the message. I hope someone will post their idea here. Thanks in Advance. --CHILL I am using this a modal window(jBox) - with a web Form in it, that requires the Form (just Name & Email) to be completed and Submitted in order to close the modal window - allowing access to the main page. The Form uses this corresponding ../submit.php which this: if (empty($_POST['name'])|| empty($_POST['email'])){ $response['success'] = false; } else { $response['success'] = true; } echo json_encode($response); where, upon Form > submit, successfully shows 'error' if the Form fields are not populated, and 'success' when the Form fields are populated/submitted.
I'd like the Form to require a proper/valid email address and avoid spam and header injection Any assistance/guidance is appreciated
This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=359169.0 I have made a form that asks a user for email, first name, last name, and password. I am using Spry validation tools in Dreamweaver. When I used those only, I did not have a problem. The problem began once I tried to actually check to see if the email was already registered. I have tried changing so many things like what $_POST variable to look for at the beginning, to different db connection arrangements. I am stumped. The only other thing I can think of is that I have the order wrong somehow in the logic. Thanks for the help. First, here is the form: Code: [Select] Enter Email<?php if($error_email_taken) echo ": $error_email_taken."; ?> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <input name="email" type="text" id="email" value="<?php if($_POST["email"]) echo $_POST["email"]; ?>"> <input name="first" type="text" id="first" value="<?php if($_POST["first"]) echo $_POST["first"]; ?>"> <input name="last" type="text" id="last" value="<?php if($_POST["last"]) echo $_POST["last"]; ?>"> <input name="pass" type="password" class="formText1" id="pass" value="<?php if($_POST["pass"]) echo $_POST["pass"]; ?>"> <input type="submit" name="Submit" value="Submit"></td> </form> And the email verification and insert, which is placed before the opening html tag. Code: [Select] <?php if($_POST['Submit']) { //Check to see if email is registered. $email = $_POST['email']; $dbc=mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $q_1 = "SELECT users_email FROM table WHERE users_email = $email"; $r_1 = mysqli_query($dbc, $q_1); $rows_1 = mysqli_num_rows($r_1); if ($rows_1 == 0) { //If 0, email is not already registered. $new_email = $_POST['email']; } else { $error_email_taken = "This email is already registered."; } //If everything is good, insert the information. if(isset($new_email)) { $first_name = $_POST['first']; $last_name = $_POST['last']; $password = $_POST['pass']; //Insert User information. $q_2 = "INSERT INTO table (users_email, users_first, users_last, users_pass) VALUES ('$new_email', '$first_name', '$last_name', '$password')"; $r_2 = mysqli_query($dbc, $q_2); //Go to new page if form was submitted and information properly inserted. header('Location: new_page.php'); }//End: if($new_email) } //End: if $_POST['submit'] ?> I've simplified it as much as I could. I totally eliminated stuff like a password hash, etc. because I wanted to get it down to the most simple form, so once this gets working, I'll add that other stuff later. Thanks so much again. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=349030.0 Hi, I was going to through a PHP tutorial, and came across a form validation user defined function . Below is an example.. Code: [Select] function check_required_fields($fields){ $field_errors = array(); foreach ($fields as $requried_fields) { if (!isset($_POST[$requried_fields]) || (empty($_POST[$requried_fields]) && $_POST[$requried_fields] != 0)) if (!isset($_POST[$fieldname]) || (empty($_POST[$fieldname]) && $_POST[$fieldname] != 0)) { $errors[] = $requried_fields; } } return $field_errors; } When the user defined function was called they added an $_POST and the end of the user defined function. Here is a the code snipped of how it looks Code: [Select] $errors = array(); // perform validations on the form data $required_fields = array('username', 'password'); $errors = array_merge($errors, check_required_fields($required_fields, $_POST)); If the validation can be preformed with out the $_POST, why bother inserting it? Thanks! Hello, I have created a sing up form with email, password and captcha. I verify at submit all the possible errors and it works except one, for example you fill the email field with non existing email in db, the 2 password field with same pass and fill the captcha field wrong. In this example it will proceed inserting the data in the db, i cannot figure what is wrong please advise. register.php <?php session_start(); include('include/config.php'); include('include/validation.php'); include('include/header.php'); ?> <div id="register"> <h1>Inregistrare</h1> <?php if(isset($_POST['send']) && (!validateEmail($_POST['email']) || !validatePasswords($_POST['pass1'], $_POST['pass2']) || !validateRegister())): ?> <div id="error"> <ul> <?php if(!validateEmail($_POST['email'])): ?> <li><strong>E-mail invalid:</strong> Introduceti o adresa de email valida.</li> <?php endif ?> <?php if(!validatePasswords($_POST['pass1'], $_POST['pass2'])): ?> <li><strong>Parole invalide:</strong> Parolele nu se potrivesc sau sunt mai mici de 5 caractere!</li> <?php endif ?> <?php if(!validateCaptcha($_POST['code'])): ?> <li><strong>Cod invalid:</strong> Cod invalid.</li> <?php endif ?> <?php if(!validateRegister()): ?> <li><strong>Exista:</strong> exista.</li> <?php endif ?> </ul> </div> <form method="post" id="register" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>"> <div> <label for="email">E-mail</label> <input id="email" name="email" type="text" /> <span id="emailInfo">Adresa Dvs. de email va fi folosita pentru login.</span> </div> <div> <label for="pass1">Parola</label> <input id="pass1" name="pass1" type="password" /> <span id="pass1Info">Parola trebuie sa contina cel putin 5 caractere.</span> </div> <div> <label for="pass2">Confirma Parola</label> <input id="pass2" name="pass2" type="password" /> <span id="pass2Info">Confirma parola</span> </div> <div><img src="include/captcha.php" /></div> <div> <label for="code">Introduceti codul de mai sus</label> <input id="code" type="text" name="code" /> <span id="codeInfo">Sunteti om?</span> </div> <div> <input id="send" name="send" type="submit" value="Inregistrare" /> </div> </form> <?php elseif(isset($_POST['send'])):?> <div id="error" class="valid"> <ul> <li><strong>Felicitari!</strong> Datele de login au fost trimise la adresa <?php echo $_POST['email']; ?></li> </ul> </div> <?php $email=trim($_POST['email']); $password=md5($_POST['pass1']); $query="INSERT INTO users (email, password) VALUES ('$email', '$password')"; $result_query=mysql_query($query) or die('EROARE MYSQL'); ?> <?php endif ?> <?php if(!isset($_POST['send'])):?> <form method="post" id="register" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>"> <div> <label for="email">E-mail</label> <input id="email" name="email" type="text" /> <span id="emailInfo">Adresa Dvs. de email va fi folosita pentru login.</span> </div> <div> <label for="pass1">Parola</label> <input id="pass1" name="pass1" type="password" /> <span id="pass1Info">Parola trebuie sa contina cel putin 5 caractere.</span> </div> <div> <label for="pass2">Confirma Parola</label> <input id="pass2" name="pass2" type="password" /> <span id="pass2Info">Confirma parola</span> </div> <div><img src="include/captcha.php" /></div> <div> <label for="code">Introduceti codul de mai sus</label> <input id="code" type="text" name="code" /> <span id="codeInfo">Sunteti om?</span> </div> <div> <input id="send" name="send" type="submit" value="Inregistrare" /> </div> </form> <?php endif ?> </div> <?php include('include/footer.php'); ?> validation.php <?php function validateName($name){ //if it's NOT valid if(strlen($name) < 4) return false; //if it's valid else return true; } function validateEmail($email){ return ereg("^[a-zA-Z0-9]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$", $email); } function validatePasswords($pass1, $pass2) { //if DOESN'T MATCH if(strpos($pass1, ' ') !== false) return false; //if are valid return $pass1 == $pass2 && strlen($pass1) > 4; } function validateMessage($message){ //if it's NOT valid if(strlen($message) < 10) return false; //if it's valid else return true; } function validateCaptcha($code) { if($code == $_SESSION['rand_code']) //if it's valid return true; else //if it's NOT valid return false; } function validateRegister() { $query_check_login="SELECT email FROM users WHERE email='".$_POST['email']."' LIMIT 1"; $result_check_login=mysql_query($query_check_login) or die('MYSQL ERROR'); $row_check = mysql_num_rows($result_check_login); if($row_check == 1){ //if it's NOT valid return false; } else { //if it's valid return true; } } ?> |