Page 1 of 1
Post to another function, but returning to old?
Posted: Sun Aug 11, 2002 10:54 am
by jidospod
Here's my problem, I'm writing a user interface in PHP using mysql.
My script is called lets say "bleh.php" now by default, it loads a LOGIN screen, that login screen has a link to REGISTER. If the user clicks the REGISTER link, it takes them to the REGISTER screen, but the login page loads at the bottom of the page as well. Is there any way I can make it NOT load the LOGIN info if the user went to the register function? I am at a complete loss here. Any help would be greatly appreciated.
Thanks.
Yes
Posted: Sun Aug 11, 2002 11:12 am
by w3cynic
A simple conditional would do that;
Code: Select all
if ($register != "true")
{
include('login.php');
}
If the login is not a seperate file then simply specify the conditional for the function.
Posted: Sun Aug 11, 2002 4:01 pm
by jidospod
Its all one php file though. So I have tried it with multiple arguments. for each procedure it does end up calling. Wondering if there is a better way to do this.

Posted: Sun Aug 11, 2002 4:16 pm
by daemorhedron
it's not so much the include() part, but the if() part that is important there. you should be able to do
if (condition) {
REGSTER CODE HERE
} else {
LOGIN CODE HERE
}
or something along those lines at any rate. it might be worthwhile for you to move these into their own functions (if they aren't already) and look into call_user_func();
remember to always authenticate your data! =)
HTH
Posted: Sun Aug 11, 2002 7:12 pm
by jidospod
daemorhedron wrote:it's not so much the include() part, but the if() part that is important there. you should be able to do
if (condition) {
REGSTER CODE HERE
} else {
LOGIN CODE HERE
}
or something along those lines at any rate. it might be worthwhile for you to move these into their own functions (if they aren't already) and look into call_user_func();
remember to always authenticate your data! =)
HTH
Its not all in the same function, they are all in their own.. But the main section of code, has the login box (just basically HTML), then there is a register button there that calls user_registration(), but it keeps putting the login info below it, I solved it with this simple fix you told me, but I am not that familiar with call_user_func(); Could you give me an example of how it could be used?
Posted: Sun Aug 11, 2002 7:22 pm
by hob_goblin
ok try this:
Code: Select all
<?
/* put all the register stuff and login stuff into their own function */
$id = $_GETї'id'];
switch($id){
case "log":
/* login function */
break;
default:
/* register function */
}
and then load the page, and make the link to login bleh.php?id=log , and bleh.php would just always load the register function.. (but not the login)
Posted: Sun Aug 11, 2002 10:49 pm
by jidospod
Thanks that should work out nicely. I will give it a try in the morning, dead tired at the moment.

Posted: Mon Aug 12, 2002 1:11 pm
by jidospod
Thanks, using the case option you gave me works great, now Im in another problem. lets say ?id=login, ok they go to html for login, fill it out, and when they click submit it just goes right back to login info.. I didnt have this problem before I mereged everything into one file (as requested by the customer). How can I make it once they fill out login info have the form call userlogin(); with the username and password variables passed to it?