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.
// 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:
Originally Posted by Cid
The FORM works but doesn't come back fast enough for next User.
// 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:
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.
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?
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.
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!
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
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?
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
Bookmarks