Login.php help please

Hi Everyone,

I am using the information in this article http://wiki.mikrotik.com/wiki/HotSpot_external_login_page to login through my website and it works fine, but I have what I think is a unique situation that I need some help with, but perhaps some of you are doing the same or a similar thing as me…

I want it to work like this:

login.php on my website needs to have a small banner ad coded in it that is clickable. I have created the banner ad and added the code to the login.php file. It displays fine.

When the banner is clicked, I want it to load login2.php (an exact duplicate of the code in login.php, except with a different banner ad picture that the user can click to go to a website or ignore and click the “free trial” to use the internet).

The problem I seem to have is that the banner ads display perfectly on login.php and login2.php, the “free trial” works fine on the login.php page, but from login2.php the “free trial” doesn’t work. When I click it, it is as if nothing happens and it stays on the page without allowing free internet access. I can only presume that it doesn’t work from the login2.php page because it must have lost it’s variables settings? If I press the back button to go back to login.php page, the free trial works again.

Can someone please help me figure this out. I will pay for consulting, I really need ot get this working.

Thanks!
Rick

You should probably pass the variables, like you said.

first catch them in login.php

   $mac=$_POST['mac'];
   $ip=$_POST['ip'];
   $username=$_POST['username'];
   $linklogin=$_POST['link-login'];
   $linkorig=$_POST['link-orig'];
   $error=$_POST['error'];
   $chapid=$_POST['chap-id'];
   $chapchallenge=$_POST['chap-challenge'];
   $linkloginonly=$_POST['link-login-only'];
   $linkorigesc=$_POST['link-orig-esc'];
   $macesc=$_POST['mac-esc'];

Then on banner click send them to login2.php (code below just shows a submit button to test it)

<form name="send" action="login2.php" method="post">
<input type="hidden" name="mac" value="$mac">
<input type="hidden" name="ip" value="$ip">
<input type="hidden" name="username" value="$username">
<input type="hidden" name="link-login" value="$link-login">
<input type="hidden" name="link-orig" value="$link-orig">
<input type="hidden" name="error" value="$error">
<input type="hidden" name="chap-id" value="$chap-id">
<input type="hidden" name="chap-challenge" value="$chap-challenge">
<input type="hidden" name="link-login-only" value="$link-login-only">
<input type="hidden" name="link-orig-esc" value="$link-orig-esc">
<input type="hidden" name="mac-esc" value="$mac-esc">
<input type="submit" value="continue">
</form>
<script language="JavaScript">
<!--
   document.send.submit();
//-->
</script>

then on login2.php catch 'm again:

 $mac=$_POST['mac'];
   $ip=$_POST['ip'];
   $username=$_POST['username'];
   $linklogin=$_POST['link-login'];
   $linkorig=$_POST['link-orig'];
   $error=$_POST['error'];
   $chapid=$_POST['chap-id'];
   $chapchallenge=$_POST['chap-challenge'];
   $linkloginonly=$_POST['link-login-only'];
   $linkorigesc=$_POST['link-orig-esc'];
   $macesc=$_POST['mac-esc'];

I think this should work…

Hi,

Thanks for the tips.

I put this on login2.php to see if values are beign passed:

Login.php Test

Mac: <?php echo $mac ?>
IP: <?php echo $ip ?>
Username: <?php echo $username ?>
Link-login: <?php echo $linklogin ?>
Link-orig: <?php echo $linkorig ?>
Error: <?php echo $error ?>
\ \ The results that I get are: Mac: $mac IP: $ip Username: $username Link-login: $link-login Link-org: $link-org Error: $error

And values are empty, so they are still not getting passed from Login.php. I am sure that it is something that I am doing wrong or missing. And yet, when I put the same code to display the values in login.php, all of the values are there.

I appreciate your help.

You should use the banner link to submit the form to the new page. Use the forms like Beone suggested (see new send form below), then use something like this for the banner link:

<a href="Javascript:void(0);" onClick="document.send.submit();">Banner here</a>

Here is the send form for login.php. I edited the code to php variables.

<form name="send" action="login2.php" method="post">
<input type="hidden" name="mac" value="<?php echo $mac; ?>">
<input type="hidden" name="ip" value="<?php echo $ip; ?>">
<input type="hidden" name="username" value="<?php echo $username; ?>">
<input type="hidden" name="linklogin" value="<?php echo $linklogin; ?>">
<input type="hidden" name="linkorig" value="<?php echo $linkorig; ?>">
<input type="hidden" name="error" value="<?php echo $error; ?>">
<input type="hidden" name="chapid" value="<?php echo $chapid; ?>">
<input type="hidden" name="chapchallenge" value="<?php echo $chapchallenge; ?>">
<input type="hidden" name="linkloginonly" value="<?php echo $linkloginonly; ?>">
<input type="hidden" name="linkorigesc" value="<?php echo $linkorigesc"; ?>">
<input type="hidden" name="macesc" value="<?php echo $macesc; ?>">
<input type="submit" value="continue">
</form>

I left the submit button so you could test it as a form before using the banner link to submit it. When the banner link is tested and working, remove the submit button from the form.

I apologize in advance for any typos. The coffee isn’t working yet.

ADD: I remove the dashes from the variable names. It can be interpreted as a subtraction in some languages. Just my preference.

Lol, still early over there? :slight_smile:
Indeed, you have to echo the variables, sorry.

It is Saturday morning just before 7am here. It took several edits to correct the code in my post.
But good news everyone! The coffee is working now! :laughing:

Hi

Thanks again for the tips. I am getting there!

Here is what its doing now:

On the login.php page, it captures variables fine. But the strange thing is that the form with the submit button on login.php page never shows when login.php page runs. It just goes automatically to login2.php and shows it’s banner. Login2.php still has variables present, which is great and I can login with free trial from login2.php.

But I am not sure why form with submit button doesn’t show and why it goes directly to login2.php without showing the banner on login.php first.

Here is my code for login.php page:

<?php $mac=$_POST['mac']; $ip=$_POST['ip']; $username=$_POST['username']; $linklogin=$_POST['link-login']; $linkorig=$_POST['link-orig']; $error=$_POST['error']; $chapid=$_POST['chap-id']; $chapchallenge=$_POST['chap-challenge']; $linkloginonly=$_POST['link-login-only']; $linkorigesc=$_POST['link-orig-esc']; $macesc=$_POST['mac-esc']; ?> ...

Logintest.php Values Before Form

Mac: <?php echo $mac ?>
IP: <?php echo $ip ?>
Username: <?php echo $username ?>
Link-login: <?php echo $linklogin ?>
Link-orig: <?php echo $linkorig ?>
Error: <?php echo $error ?>
Chap-id <?php echo $chapid ?>
\ \ And here is login2.php code: <?php $mac=$_POST['mac']; $ip=$_POST['ip']; $username=$_POST['username']; $linklogin=$_POST['link-login']; $linkorig=$_POST['link-orig']; $error=$_POST['error']; $chapid=$_POST['chap-id']; $chapchallenge=$_POST['chap-challenge']; $linkloginonly=$_POST['link-login-only']; $linkorigesc=$_POST['link-orig-esc']; $macesc=$_POST['mac-esc']; ?> ... body {color: #737373; font-size: 10px; font-family: verdana;}

textarea,input,select {
background-color: #FDFBFB;
border: 1px solid #BBBBBB;
padding: 2px;
margin: 1px;
font-size: 14px;
color: #808080;
}

a, a:link, a:visited, a:active { color: #AAAAAA; text-decoration: none; font-size: 10px; }
a:hover { border-bottom: 1px dotted #c1c1c1; color: #AAAAAA; }
img {border: none;}
td { font-size: 14px; color: #7A7A7A; }

Login2.php Test

Mac: <?php echo $mac ?>
IP: <?php echo $ip ?>
Username: <?php echo $username ?>
Link-login: <?php echo $linklogin ?>
Link-orig: <?php echo $linkorig ?>
Error: <?php echo $error ?>

Please log on

To Continue to the internet, <a style=“color: #FF8080"href=”<?php echo $linkloginonly; ?>?dst=<?php echo $linkorigesc; ?>&username=T-<?php echo $macesc; ?>">click here.



<?php echo $error; ?>

OK, I am learning :slight_smile:

The javascript is supplying the submit action to login.php, that’s why it was continuing to login2.php automatically.

Sorry, I am definitely a newbie. but it’s starting to make sense.

That is correct. You are replacing that part of the script (automatic form submit on page load) with the banner link.

BTW, The fact that you have gotten this far with this code means you are definitely NOT a newbie! :smiley: