SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Feb 2012
    Location
    Kiwi in Bangkok
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Could someone lookat the php Sign up code please

    This is a section of code from a Signup page, it is not working, not signing up.

    I was looking at the code and notice the 2 BOLD areas, the code is different, 1 is just"" and the 2nd has "empty"

    could someone tell me if this is correct? and what is correct ? Thank you

    session_start();
    $username = cleanInput($_POST['username']);
    $password = cleanInput($_POST['password']);
    $firstname = cleanInput($_POST['firstname']);
    $surname = cleanInput($_POST['lastname']);
    $email = cleanInput($_POST['email']);
    $age = cleanInput($_POST['age_list']);
    $children = cleanInput($_POST['children']);


    if ( $firstname!="" and $surname!="" and $email!="" and $age!="empty" and $children!="empty" and $gender!="empty" and $sexuality!="empty" and $build!="empty" and $height!="empty" and $area!="empty" and $town!="empty" and $employment!="empty" and $diet!="empty" and $drink!="empty" and $smoke!="empty" and $religion!="empty" ) {

    $newMember = new Member();
    $newMember->firstname = $firstname;
    $newMember->surname = $surname;
    $newMember->username = $username;

  2. #2
    SitePoint Evangelist
    Join Date
    Oct 2005
    Location
    Michigan, USA
    Posts
    434
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    That could be right but not likely. Typically the default value of any form input is the empty string (that is, nothing or "" as you've seen). Those others are checking against the word "empty". If your form loads and actually shows the word "empty" in a bunch of fields, then that code could be right. But if the fields are just blank, then they should be like $age != "" and $children != "" ...
    - Robert

  3. #3
    SitePoint Addict
    Join Date
    Feb 2012
    Location
    Kiwi in Bangkok
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you QMonkey for your quick helpful reply,

    yes the difference is what alerted me, I will place "empty" inside those that are without empty and see what happens

    best wishes

  4. #4
    SitePoint Addict
    Join Date
    Aug 2006
    Location
    Nantwich, Cheshire
    Posts
    282
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    As well as the form, the cleanInput() function may return the string 'empty' in certain circumstances, though it's hard to see why it would not be consistent.
    http://www.firenza.net - my homage to a car from the 1970s


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •