Jump to content

Y2Jackie

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Y2Jackie's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Using those preg_match tuts, I got it working I'm trilled. You're a life saver!
  2. Thanks nrg_alpha, the email code is working nicely. Now I'll get into the preg and see if I can get spaces to validate.
  3. I'm testing on my server then I have to upload to theirs so would it not be important if their PHP version differed to mine? They bought their hosting before talking to me. I'm not hosting any of their stuff on my personal domain.
  4. Thanks for your reply. I used the integer firstly because it was in a tut I was looking at and secondly because I find it an easy way for me to visualise the true false. I appreciate that it's not required but it's not going to mess up my code, is it? I had a quick look at the preg/pcre info. I think I'd get it better if I had time to sit down and go through it properly but unfortunately time is of essence... and I'm a Flash designer by trade haha. Lord, I don't know what have I got myself into here I think I'll try again a little later and hopefully I can get the syntax down. I appreciate knowing that the eregi is going to be outdated soon, tho it's a bummer I've been wasting my time with it. With the email sanitisation that you've quoted, how would I call it so I can do different things if it's true or false? Is it: if (validate_email == "true"){ //true statement }else{ //false statement } I'm not looking for something too specific, just something that will allow more than just .com adresses. Re: Ken2k7, I believe filter_input() is available for me. I know my host uses a recent enough version of PHP for it, I can't check my clients because I don't have his login details at work, but I'm pretty sure it's the same as mine. As for email format validation, this is a tough one.. You can read this post (Reply #3) to see links to an email parser already built for this very purpose. As for me personally, I don't even bother using strict email format validations and instead vouch for a much more relaxed filter_var in conjunction with FILTER_SANITIZE_EMAIL and FILTER_VALIDATE_EMAIL pre defined constants. Example: function validate_email($the_email){ return(filter_var(filter_var($the_email, FILTER_SANITIZE_EMAIL),FILTER_VALIDATE_EMAIL))? true : false ; } Granted, this isn't bulletproof (but then again, it isn't meant to be). It's just a much less tightfisted version (more relaxed). But if you need ultra strict email validation, then by all means, the link I provided above would do nicely. If you're interested in learning PCRE, below are some resources to help get you started in learning preg: Regular Expressions WeblogToolsCollection Mastering Regular Expressions PhpFreaks Resources PHPFreaks Tutorial
  5. Hi, I have a few expressions that aren't working how I would like them to. Currently I have: $validate1 = eregi('[^a-z\s\-]', $FirstName); $validate1 = (int)$validate1; $validate2 = eregi('[^a-z\s\-]', $Surname); $validate2 = (int)$validate2; $validate3 = eregi('[^0-9\s+]', $HomePhone); $validate3 = (int)$validate3; $validate4 = eregi('[^0-9\s+]', $MobilePhone); $validate4 = (int)$validate4; $validate5 = eregi('^[^0-9][a-z0-9_]+([.][a-z0-9_]+)*[@][a-z0-9_]+([.][a-z0-9_]+)*[.][a-z]{2,4}', $EmailAddress); $validate5 = (int)$validate5; $validate6 = eregi('[^0-9]', $Postcode); $validate6 = (int)$validate6; $validate7 = eregi('[^a-z\s\-]', $Suburb); $validate7 = (int)$validate7; $validate8 = eregi('[^0-9a-z\s\-]', $Address); $validate8 = (int)$validate8; which are later called by an if statement and then an echo is done for each failure. if ($validate1 == 0 && $validate2 == 0 && $validate3 == 0 && $validate4 == 0 && $validate5 == 0 && $validate6 == 0 && $validate7 == 0 && $validate8 == 0) { } //send email etc. }else{ //Explanation of Fail echo "Sorry, you seem to have entered invalid information into the form. Below is an explanation of the error/s:<ul>"; if ($validate1 == 1) { echo "<li>The first name you have entered contains invalid characters. It can only contain letters and - (hyphen/dash).</li>"; ... ... ... } I've checked that all my variables relate to the correct fields. Firstly, none of these seem to be working if I enter a space. I've tried using \s but it's not working. My email address validates any ol thing. I would ultimately like something that will allow addresses with .com.au, .co.uk etc. With address and suburb I would also like to add an apostrophe ('). I've tried ' and \' but neither seem to be working. I've been looking up stuff for days but aren't having any luck. Would be very very thankful for any help. Thanks!
  6. Thanks Matthew and Mike, I've got it working now
  7. I've tried it but it doesn't seem to be working I've tried "Choose" and "Please Choose"
  8. Hi, I'm a noob at PHP (this is my first script) but need to use it so I can add in the reCaptcha code. It all works except for one thing... In my form file I have: <select name="contactMethod" id="contactMethod"> <option selected="selected">Please Choose</option> <option>Home Phone</option> <option>Mobile Phone</option> <option>Email</option> </select> In my sendmail.php file I have the following statement: if (!isset($_REQUEST['emailAddress'])) { header("Location: myformlink.php"); } elseif (empty($EmailAddress) || empty($Enquiry) || empty($FirstName) || empty($Surname) || empty($ContactMethod)){ header("Expires: Mon, 20 Dec 1998 01:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); where $ContactMethod = $_REQUEST['contactMethod']; Because "Please Choose" is automatically selected, it validates as if the user has selected it. I need Please Choose at the top, but I also need the script to be able to understand that if that is selected, then it is to consider it as if it has no information and fail the test. Is this possible? Thank you! Jackie
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.