www.webdeveloper.com
Results 1 to 4 of 4

Thread: User input varification

Hybrid View

  1. #1
    Join Date
    Apr 2013
    Posts
    3

    Question User input varification

    Iíve written code (below) of which receives posted fields data on to the acknowledgement page (Subscribe page > Acknowledge page), however the code is not working as expected so Iíve removed the other code (mainly the sanitizing of user input) and left the code were the users input is checked for empty spaces. This still isnít working...Iím a rooky, so any help is much appreciated

    PHP Code:
    if($_POST['username'] === "" ||$_POST['userfirstname']=== ""|| $_POST['usersecondname']=== ""||$_POST['useremail']=== ""||$_POST['userpassword']=== ""||
        
    $_POST['userpasswordr']=== "")
     
        {    
     
        
    $arr_fields = array("$_POST['username']""$_POST['userfirstname']""$_POST['usersecondname']""$_POST['useremail']",
                            
    "$_POST['userpassword']""$_POST['userpasswordr']");
     
        foreach(
    $arr_fields as $arr_field)
        {
     
            if(
    $arr_field == "")
                {
                    
    $arr_field "missing";
     
                }
     
        }
        
            
    $var_username=            $_POST['username'];
            
    $var_userfirstname=        $_POST['userfirstname'];
            
    $var_usersecondname=        $_POST['usersecondname'];
            
    $var_useremail=            $_POST['useremail'];
            
    $var_userpassword=        $_POST['userpassword'];
            
    $var_userpassword_repeat=     $_POST['userpasswordr'];
            
            
    $arr_fields_processed = array("$var_username""$var_userfirstname""$var_usersecondname""$var_useremail",
                             
    "$var_userpassword""$var_userpassword_repeat");
            
            
    header ("location: subscribe.php?arr_fields_processed");
     
         } else 
     

             {
        
            
                  
    //sanitize code...
            
             


  2. #2
    Join Date
    May 2003
    Posts
    598
    Your enclosing "if" statement is saying only process the input "if" one of those fields is identical to blank...so unless one of the defined fields is in fact identical to blank, no code will be processed.
    We do precision guesswork

  3. #3
    Join Date
    May 2003
    Posts
    598
    If your goal is simply to check if an input is blank I would include the step within the sanitization itself like this:
    PHP Code:

    foreach($_POST as $key=>$val){
    if(
    $val ==''){
    //flag it
    }else{
    //sanitize it
    }

    We do precision guesswork

  4. #4
    Join Date
    Apr 2013
    Posts
    3
    Thanks hastx...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles