Jump to content

Love2c0de

Members
  • Content Count

    364
  • Joined

  • Last visited

  • Days Won

    1

Love2c0de last won the day on January 2 2013

Love2c0de had the most liked content!

Community Reputation

12 Neutral

About Love2c0de

  • Rank
    Advanced Member
  • Birthday 05/03/1989

Contact Methods

  • Website URL
    http://www.tspv-websites.co.uk
  • Skype
    Thomas_c0de

Profile Information

  • Gender
    Male
  • Location
    The Pleiades
  • Interests
    Coding, Money
  • Age
    23
  1. Good morning, I have a wordpress theme I am using and I thought all was working well. I've noticed that when I'm not logged into admin, it doesn't show any pages for me, only white pages. When I switched back to the default TwentyTwelve theme, it worked all ok for me. Has anyone had this problem before? Thanks for your time. Kind regards, L2c
  2. Love2c0de

    handling checkboxes

    Good afternoon, How would I handle inserting checkboxes into a mysql database? I have a form which has a list of services in checkbox format as well as other fields and I want to save the values to a database but I want to be able to query the database by service if needs be. How do I deal with multiple services from checkboxes? Would I create another table called 'services' for example with columns - 'service1','service2','service3' etc etc and a unique id relating to my contact table? Thank you for your help. Kind regards, L2c
  3. Good evening, I've just validated a form with jQuery/JavaScript and I'm looking to basically do the same validation with PHP. I'm starting off by trimming all of the fields, then I'm going to check the required fields to see if they are empty or not. If so I want to send them back to the page but I need to display the errors next to the specific input fields and I'm not sure how to do it. I understand im going to have to save the error array into a session and then print the values, but I'm not sure how to map them to the correct input field. Can anyone help me? Here is my JavaScipt: $( "#reg-form" ).submit(function(e) { $('.arrow_box').css("display","none"); //hold required field values var reqFields = new Array(); //holds indexes of empty required fields var emptyInputs = new Array(); //holds form controls and will match up with emptyInputs array to determine which error box to show var formControls = new Array(); //get the value from all required fields $('.required').each(function(){ reqFields.push($(this).val()); }); //trim each required field and push any empty fields into the emptyInputs array $.each(reqFields, function(key,value){ if($.trim(value) == "") { emptyInputs.push(key); } }); //get all error divs $('.arrow_box').each(function(){ formControls.push($(this)); }); if(emptyInputs.length > 0) { e.preventDefault(); //get values from emptyInputs to determine the index of the formControls to show $.each(emptyInputs, function(k,v){ $(formControls[v]).css("display","block").prev('input').focus(); }); $(formControls[emptyInputs[0]]).prev('input').focus(); } else { //continue in-depth validation on each specific field var fname = $('#fname'); var lname = $('#lname'); var email = $('#email'); var dob = $('#dob'); var mphone = $('#mphone'); var wphone = $('#wphone'); var ages = $('#ages'); var nameRegExp = /^[a-zA-Z\s]*$/; var numRegExp = /\d+/g; var emailRegExp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; if(!nameRegExp.test($(fname).val())) { emptyInputs.push($(fname).next()); } if(!nameRegExp.test($(lname).val())) { emptyInputs.push($(lname).next()); } if(!emailRegExp.test($(email).val())) { emptyInputs.push($(email).next()); } if(!dob.val().match(numRegExp)) { emptyInputs.push($(dob).next()); } if(!mphone.val().match(numRegExp)) { emptyInputs.push($(mphone).next()); } if(!wphone.val().match(numRegExp)) { emptyInputs.push($(wphone).next()); } if(!ages.val().match(numRegExp)) { emptyInputs.push($(ages).next()); } if(emptyInputs.length > 0) { $(emptyInputs).each( function(k,v){ $(this).css("display","block"); }); $(emptyInputs[0]).prev('input').focus(); e.preventDefault(); } else { return true; } } }); Here is my PHP so far: <?php if(isset($_POST['fname'])) { $errors = array(); $required = array($_POST['fname'], $_POST['lname'], $_POST['dob'], $_POST['mphone'], $_POST['wphone'], $_POST['address'], $_POST['city'], $_POST['province'], $_POST['ages']); foreach($required as $k => &$v) { $v = trim($v); if(empty($v)) { array_push($errors, true); } else { array_push($errors, false); } } if(in_array(true, $errors, true)) { $_SESSION['msg'] = $errors; header("Location: Register-Now.php"); die(); } echo "<pre>"; var_dump($errors); echo "</pre>";die(); } else { //someone has tried to directly access the form script without a submit, send them back! header("Location: Register-Now.php"); die(); } ?> Really stuck, can anyone help me with this problem? Thank you for your time. Kind regards, L2c.
  4. Love2c0de

    alternative to a captcha/recaptcha

    Hi Denno, Thanks for the reply and advice. So it wouldn't actually be an <input> with the type of hidden but an <input> with the type of text with a CSS declaration of display:none? I've just used that technique but used an <input> with type hidden. I suppose it would have to be of type text in order for a bot to be able to fill it in? Not sure how bots work! Kind regards, Tom
  5. Good morning, I have a captcha on my website but for some reason within the last day everytime the page loads it automatically focuses on the captcha input field. I've found a couple things on the net of someone with the same issue but I can't seem to resolve it. Captcha is an ugly little thing anyway and wondered if there are any alternatives out there? I've seen forms asking to find the sum of 2 numbers but not sure how secure that is from bots. Thank you very much for your time. Kind regards, L2c
  6. Need my WAMP Server argggghhh got no server :(

  7. PHP number plate! :)

  8. Perfect Dark - N64 - old skooooo

  9. Boss told me he's gonna put me with the developr for a while and get me doing some codingzz!!! w00000p w00000p :D

    1. Love2c0de

      Love2c0de

      better swat up on my c# baby

  10. a state of trance

  11. dang theres more to Excel than I anticipated VLOOKUP >:@

  12. woop woop and another week

  13. Got a weeks trial at a web development company starting monday. Doing some data inputting. Absolutely cacking it! :o

  14. 4am, matches keeping eyelids open, eyes stingin, there just aint enough hours in the day for this. pillow....where are you?

×

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.