www.webdeveloper.com
Results 1 to 10 of 10

Thread: Why Can't I Make My PHP Form Ready For A New Registration And/OR Login?

  1. #1
    Join Date
    Jan 2012
    Location
    Eastern United States
    Posts
    38

    Why Can't I Make My PHP Form Ready For A New Registration And/OR Login?

    Hello,

    Is there any one out there that can help me with this?
    How do I make my require('reg_form_detail.php'); re-appear immediately, and ready for next User login after shutting down the browser?

    I am still kinda new to php coding. Is there another way that I can write this code to make it work. Please take a look at my code below and if possible
    give me a sample and/or add code into my code. The FORM works but doesn't come back fast enough for next User.

    Please Advise I would be most thankful!

    Cid

    Email:

    Kirkpatrick.rich7@gmail.com

    p.s. Please insert real changes to my code:

    <?php

    //Ric Kir (script for pop up )

    //if($_SERVER['REMOTE_ADDR']=='115.240.51.183'){

    if(!isset($_COOKIE['user_id']) &&($_COOKIE['user_id']<1)){

    require('reg_form_detail.php');

    }

    //}

    ?>

  2. #2
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    For one... this IF is kind of redundant.

    PHP Code:
    if(!isset($_COOKIE['user_id']) &&($_COOKIE['user_id']<1)){

    // should this first part be isset($_COOKIE['user_id']) ? rather than !isset() [NOT is set] ?

    // if the cookie "is not set", then it's value is NULL, which WILL pass the "NULL < 1" check, 
    // and the require() is reached, but it's good practice to avoid checking variables that don't exist

    // if the cookie IS set, then it won't pass the "is not set" check, thus the require() is not reached.

    require('reg_form_detail.php');



    I don't follow what you mean by this:

    Quote Originally Posted by Cid
    The FORM works but doesn't come back fast enough for next User.

  3. #3
    Join Date
    Jan 2012
    Location
    Eastern United States
    Posts
    38
    Quote Originally Posted by OctoberWind View Post
    For one... this IF is kind of redundant.

    PHP Code:
    if(!isset($_COOKIE['user_id']) &&($_COOKIE['user_id']<1)){

    // should this first part be isset($_COOKIE['user_id']) ? rather than !isset() [NOT is set] ?

    // if the cookie "is not set", then it's value is NULL, which WILL pass the "NULL < 1" check, 
    // and the require() is reached, but it's good practice to avoid checking variables that don't exist

    // if the cookie IS set, then it won't pass the "is not set" check, thus the require() is not reached.

    require('reg_form_detail.php');



    I don't follow what you mean by this:

    Hello OctoberWind,

    Thanks for your response!
    You're right. The Code that you have is not the intended code that I wanted to post. Please check out the correct code below and tell me how to correct the Registration Form, in order for it to pop-up every time a User come to the site. Here is the code:

    <?php

    //Kir Ric (script for pop up )


    //if(!empty($_SERVER['REMOTE_ADDR']=='115.240.51.183'){

    if(@!isset($_COOKIE['user_id']) &&($_COOKIE['user_id']<1)){



    require('reg_form_detail.php'); // require your form detail page



    }


    //}


    ?>

  4. #4
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    No offense, but you really didn't fix anything by adding the "error suppression" in there. You're still checking if a variable is NOT set... and if that passes, checking the variable you just confirmed was NOT set is within a particular range (less than 1).

    You either need to make sure the cookie DOES exist or switch the operator from && (and) to || (or):

    PHP Code:
    if(
        (!isset(
    $_COOKIE['user_id'])) ||     // the var is NOT set
                                            // OR
        
    ($_COOKIE['user_id']<1)            // the var is less than 1
    ) {
         require(
    'reg_form_detail.php'); 
       } 

    That said, what are the conditions that need to be met for the "pop up" to show? Your code suggests this is the sign up form, which leads me to believe my above suggestion is accurate, where by someone with a user_id is already signed up, thus doesn't need to sign up again.

  5. #5
    Join Date
    Jan 2012
    Location
    Eastern United States
    Posts
    38
    Quote Originally Posted by OctoberWind View Post
    No offense, but you really didn't fix anything by adding the "error suppression" in there. You're still checking if a variable is NOT set... and if that passes, checking the variable you just confirmed was NOT set is within a particular range (less than 1).

    You either need to make sure the cookie DOES exist or switch the operator from && (and) to || (or):

    PHP Code:
    if(
        (!isset(
    $_COOKIE['user_id'])) ||     // the var is NOT set
                                            // OR
        
    ($_COOKIE['user_id']<1)            // the var is less than 1
    ) {
         require(
    'reg_form_detail.php'); 
       } 

    That said, what are the conditions that need to be met for the "pop up" to show? Your code suggests this is the sign up form, which leads me to believe my above suggestion is accurate, where by someone with a user_id is already signed up, thus doesn't need to sign up again.
    Yes, that is correct: Someone with a user_id is already signed up, thus doesn't need to sign up again. However, still that someone just need to login.
    Therefore, the FORM still need to pop-up to allow login.

    Now how do I incorporate this code without getting a blank page or code overwrite on document? Thanks! Please advise?

  6. #6
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    Quote Originally Posted by Cid View Post
    Yes, that is correct: Someone with a user_id is already signed up, thus doesn't need to sign up again. However, still that someone just need to login.
    Therefore, the FORM still need to pop-up to allow login.

    Now how do I incorporate this code without getting a blank page or code overwrite on document? Thanks! Please advise?
    Sounds like you need an "else" block:

    PHP Code:
    if( 
        (!isset(
    $_COOKIE['user_id'])) ||     // the var is NOT set 
                                            // OR 
        
    ($_COOKIE['user_id']<1)            // the var is less than 1 
    ) { 
         require(
    'reg_form_detail.php');    // here is your "registration" form for new members
       
    } else {
         require(
    'login_form_detail.php');    // here is your "login" form for existing users
       

    If the form (reg_form_detail.php) is the same for both "new" and "current" members, then this logic is probably best served inside the reg_form_detail.php doc, to show/hide various fields.

  7. #7
    Join Date
    Jan 2012
    Location
    Eastern United States
    Posts
    38
    Quote Originally Posted by OctoberWind View Post
    Sounds like you need an "else" block:

    PHP Code:
    if( 
        (!isset(
    $_COOKIE['user_id'])) ||     // the var is NOT set 
                                            // OR 
        
    ($_COOKIE['user_id']<1)            // the var is less than 1 
    ) { 
         require(
    'reg_form_detail.php');    // here is your "registration" form for new members
       
    } else {
         require(
    'login_form_detail.php');    // here is your "login" form for existing users
       

    If the form (reg_form_detail.php) is the same for both "new" and "current" members, then this logic is probably best served inside the reg_form_detail.php doc, to show/hide various fields.
    This code almost works, only it stops page from being redirected after login?
    I'm assuming I'm loadding the code in a proper position inside the reg_form_detail.php doc? Advise...Thanks!

  8. #8
    Join Date
    Jan 2012
    Location
    Eastern United States
    Posts
    38
    I executed this code. However, I'm still having a problem getting around blank page and overwrite on pages? Please can you tell me how to correct this? Thanks

  9. #9
    Join Date
    Jan 2012
    Location
    Eastern United States
    Posts
    38
    Quote Originally Posted by Cid View Post
    This code almost works, only it stops page from being redirected after login?
    I'm assuming I'm loadding the code in a proper position inside the reg_form_detail.php doc? Advise...Thanks!
    I'm still having a problem trying to get this code to work even when installed in reg_form_detail.php?

  10. #10
    Join Date
    Jan 2012
    Location
    Eastern United States
    Posts
    38
    Quote Originally Posted by OctoberWind View Post
    Sounds like you need an "else" block:

    PHP Code:
    if( 
        (!isset(
    $_COOKIE['user_id'])) ||     // the var is NOT set 
                                            // OR 
        
    ($_COOKIE['user_id']<1)            // the var is less than 1 
    ) { 
         require(
    'reg_form_detail.php');    // here is your "registration" form for new members
       
    } else {
         require(
    'login_form_detail.php');    // here is your "login" form for existing users
       

    If the form (reg_form_detail.php) is the same for both "new" and "current" members, then this logic is probably best served inside the reg_form_detail.php doc, to show/hide various fields.
    I executed this code. However, I'm still having a problem getting around blank page and overwrite on pages? Please can you tell me how to correct this? Thanks

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