Jump to content



Photo
- - - - -

new admin link always ask for login

link admin intern new page login href

This topic has been archived. This means that you cannot reply to this topic.
18 replies to this topic

#1   GLime

GLime
  • Members
  • 30 posts

Posted 27 June 2012 - 14:56

Good morning everyone,

I have a quick question for an experienced OSCommercer.

I have made a few custom admin pages for my website which work pretty well.
However, when I link these pages to my existing default admins pages OSCommerce always ask me to login a second time.

I would like to know what to add to my links (<a href="..." ></a> ) in order to prevent a re-login from the administrator.

Thank you,


GLime

#2   multimixer

multimixer

    Lemons or Melons ?

  • Partner
  • 4,560 posts

Posted 27 June 2012 - 15:01

It ask you to login a second time, because your new admin pages are probably out of the osCommerce environment, so each time you go there, you loose the session,. So you have to login when coming back

To keep that info, you would need to use the tep_href_link() function of osCommerce

#3   GLime

GLime
  • Members
  • 30 posts

Posted 27 June 2012 - 15:18

Thanks for the quick reply, I will try that and see if it works.

#4   multimixer

multimixer

    Lemons or Melons ?

  • Partner
  • 4,560 posts

Posted 27 June 2012 - 15:26

You can use that function only if your pages are under the application_top.php "umbrella", so, within osCommerce

#5   GLime

GLime
  • Members
  • 30 posts

Posted 27 June 2012 - 15:34

Can you tell me more about this "application_top.php" so called umbrella ? Dp i have to do an include, require or something else on my custom page ? I tried doing require('custom_page.php'); But it make the whole admin section work no more.

By the way I am developping on a local server.

#6   multimixer

multimixer

    Lemons or Melons ?

  • Partner
  • 4,560 posts

Posted 27 June 2012 - 16:19

You can open any top level file of folder admin/ to check how application_top.php is getting included

Are your extra files within folder admin/ ?

#7   GLime

GLime
  • Members
  • 30 posts

Posted 27 June 2012 - 17:02

yes they are on the root of the admin folder

#8   multimixer

multimixer

    Lemons or Melons ?

  • Partner
  • 4,560 posts

Posted 27 June 2012 - 17:11

So, you can include application_top.php in the same way like it's done for the other files and use tep_href_link() for the links. You have also all other osCommerce functions available

#9   GLime

GLime
  • Members
  • 30 posts

Posted 27 June 2012 - 17:22

I tried making a link on the products_attributes.php to my custom page like so

<a href="<?php tep_href_link('custom_page.php', '', 'SSL')?>">Click here</a>

And it stills ask me for a login, even worst it bring me back to the admin index. Do I have to add the custom_page somewhere else in the code for it to work?

#10   germ

germ
  • Members
  • 13,921 posts

Posted 27 June 2012 - 20:55

<a href="<?php echo tep_href_link('custom_page.php', '', 'SSL');?>">Click here</a>

Edited by germ, 27 June 2012 - 20:57.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#11   GLime

GLime
  • Members
  • 30 posts

Posted 27 June 2012 - 20:58

Thank you Germ !! Now my links work like a charm!

#12   GLime

GLime
  • Members
  • 30 posts

Posted 28 June 2012 - 17:31

I have custom forms that i want the action to target self (action="#"). However doing so means the same issue, I tried doind the echo tep_href_link on those but it does not seem to work. Anyone knows the function i should use to prevent the login prompt and the bad redirection ?

#13   germ

germ
  • Members
  • 13,921 posts

Posted 28 June 2012 - 22:09

This works for me:

action="<?php echo basename( $_SERVER['SCRIPT_FILENAME'] );?>"
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#14   germ

germ
  • Members
  • 13,921 posts

Posted 28 June 2012 - 22:34

Better use this instead. The other code was in a "stand-alone" PHP file not running under the osC umbrella...

action="<?php echo tep_href_link(basename( $_SERVER['SCRIPT_FILENAME'] ), '', 'SSL');?>"
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#15   GLime

GLime
  • Members
  • 30 posts

Posted 29 June 2012 - 13:42

Neither seems to work for me, they still ask me to re-enter my login info.

#16   germ

germ
  • Members
  • 13,921 posts

Posted 30 June 2012 - 14:49

Doesn't make a lot of sense to me.

We're using the same code you said worked perfectly 3 posts ago.

The only difference is it's in a <form> instead of an anchor (<a href....></a>).

Unless you want to post your code or PM it to me I really don't have any idea how to "debug" something I can't see...
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#17   GLime

GLime
  • Members
  • 30 posts

Posted 06 July 2012 - 15:59

it goes like that

<form method="GET" action="<?php echo tep_href_link(basename($_SERVER['SCRIPT_FILENAME']), '', 'SSL');?>" id="frmNewModule" name="frmNewModule">

#18   germ

germ
  • Members
  • 13,921 posts

Posted 06 July 2012 - 16:53

Actually I meant the code from the entire file.

When I get home this evening I'll do some testing on my WAMP server with a PHP form I've written and see if I can duplicate your problem.

It still doesn't make any sense to me at all why it isn't working.
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#19   germ

germ
  • Members
  • 13,921 posts

Posted 06 July 2012 - 22:24

My test program using your code:

<?php
require('includes/application_top.php');
if ( $_GET[ 'fname' ] ) {
echo $_GET[ 'fname' ] . '<br>';
}
if ( $_GET[ 'lname' ] ) {
echo $_GET[ 'lname' ] . '<br>';
}
?>

<center>
<br><br><br><br><br><br><br>
<form method="GET" action="<?php echo tep_href_link(basename($_SERVER['SCRIPT_FILENAME']), '', 'SSL');?>" id="frmNewModule" name="frmNewModule">
First name: <input type="text" name="fname" /><br />
Last name: <input type="text" name="lname" /><br />
<input type="submit" value="Submit" />
</form>
<br><br>
<?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">Home' . '</a>'; ?>
</center>


I put a link to the PHP file containing the code above in the footer of the admin so I can click it after I login to the admin.

Works great - never asks for login.

Not sure what it proves other than the code you're using for the form link isn't at fault.
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >