Post to another function, but returning to old?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jidospod
Forum Commoner
Posts: 33
Joined: Tue Jun 11, 2002 1:05 am

Post to another function, but returning to old?

Post 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.
w3cynic
Forum Newbie
Posts: 12
Joined: Sun Aug 11, 2002 11:06 am

Yes

Post 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.
jidospod
Forum Commoner
Posts: 33
Joined: Tue Jun 11, 2002 1:05 am

Post 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. :)
daemorhedron
Forum Commoner
Posts: 52
Joined: Tue Jul 23, 2002 11:03 am

Post 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
jidospod
Forum Commoner
Posts: 33
Joined: Tue Jun 11, 2002 1:05 am

Post 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?
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

ok try this:

Code: Select all

<?

/* put all the register stuff and login stuff into their own function */

$id = $_GET&#1111;'id'];

switch($id)&#123;
  case "log":
  /* login function */
  break;
  default:
  /* register function */
&#125;
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)
jidospod
Forum Commoner
Posts: 33
Joined: Tue Jun 11, 2002 1:05 am

Post by jidospod »

Thanks that should work out nicely. I will give it a try in the morning, dead tired at the moment. :)
jidospod
Forum Commoner
Posts: 33
Joined: Tue Jun 11, 2002 1:05 am

Post 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?
Post Reply