Click to See Complete Forum and Search --> : PHP Logon through htaccess problem


Baby Jai
08-24-2003, 12:43 AM
Ok I have three diffrent logons in my members area. Im trying to use all of them in the same aspect. The first one works but the ones after dont.... Tell me whats wrong with the code?
<table width="100%" border="0">
<tr>
<td width="22%" height="26"><strong><font size="2" face="Arial"><a href="http://www.babyjai.com/members/" onMouseOver="window.status=this.firstChild.data; return true" onMouseOut="window.status=''; return true">Members
Shop</a></font></strong></td>
<td width="78%"> <form action="<?php echo $PHP_SELF ?>" method="POST">
<font face="Arial">
<input type="hidden" name="server" value="http://www.babyjai.com/members/">
<font size="2">Username:
<input type=text name=username size=20>
Password:
<input type=password name=password size=20>
</font></font> <font face="Arial">
<input type=button value="Login!" onClick="Login(this.form)" name="button">
</font></form></td>
</tr>
<tr>
<td height="26"><strong><font size="2" face="Arial"><a href="http://www.babyjai.com/memberspremier/" onMouseOver="window.status=this.firstChild.data; return true" onMouseOut="window.status=''; return true">Premier Members</a></font></strong></td>
<td> <form action="<?php echo $PHP_SELF ?>" method="POST">
<font face="Arial">
<input type="hidden" name="server" value="http://www.babyjai.com/memberspremier/">
<font size="2">Username:
<input type=text name=username size=20>
Password:
<input type=password name=password size=20>
</font></font> <font face="Arial">
<input type=button value="Login!" onClick="Login(this.form)" name="button">
</font></form></td>
</tr>
<tr>
<td height="26"><strong><font size="2" face="Arial"><a href="http://www.babyjai.com/memberelite/" onMouseOver="window.status=this.firstChild.data; return true" onMouseOut="window.status=''; return true">Elite Members</a></font></strong></td>
<td> <form action="<?php echo $PHP_SELF ?>" method="POST">
<font face="Arial">
<input type="hidden" name="server" value="http://www.babyjai.com/memberelite/">
<font size="2">Username:
<input type=text name=username size=20>
Password:
<input type=password name=password size=20>
</font></font> <font face="Arial">
<input type=button value="Login!" onClick="Login(this.form)" name="button">
</font></form></td>
</tr>
</table>

Nevermore
08-24-2003, 08:54 AM
Unless my reading skills have failed me, you haven't posted your PhP code.

Baby Jai
08-24-2003, 09:46 AM
look at the <?php echo $PHP_SELF ?>, its actually a PHP code on a Html page, the top code work sfine its when you get to the second and third one, here check it out here... If you enter the wrong password or whatever on the second andthird one there is a weird page. Check it out here. (http://www.babyjai.com/members.html)

Nevermore
08-24-2003, 12:22 PM
Oh, I thought that there was some processing code that you wanted checking. Sorry.

Ideas: You have missed out the quotes on your input fields - they should be like this: <input type="text" name="textarea"> etc.

If that doesn't help, is the JavaScript function Login() that you refer to working? Post it and let us check. (That is, unless you are sure it has nothing to do with the problem.)

Baby Jai
08-24-2003, 04:10 PM
I did post the link check it out and let me know what you think the problem is

pyro
08-24-2003, 10:19 PM
From the code you posted, the first one shouldn't work, either... Did you leave some code out?

Baby Jai
08-25-2003, 05:19 AM
check out the link 2 postrs up that says check it out here, it works, but the others done

pyro
08-25-2003, 07:27 AM
Are you able to log in via regular .htaccess? ie. typing the path in your browser and entering the username and password in the popup box? Without having any test usernames/passwords to try it out, all I can think is that you are not entering correct usernames/passwords. Submitting the first form with username: test and password: testpass gets me:

http://test:testpass@http://www.babyjai.com/members/

the second

http://test:testpass@http://www.babyjai.com/memberspremier/
and the third

http://test:testpass@http://www.babyjai.com/memberelite/

All the same format...

Baby Jai
08-25-2003, 01:58 PM
yes that works that way, for IE if you lcikc on the name and enter a username and password it works for all 3 of them. Then if you enter a username and password for the members it works fine as well. Then when you try either the premier or elite member ship, it works when you use the htaccess pop up box if you hit the name, but tyhe field that you fill in dont work. Do you think it is conflicty of intrests between all of them?

pyro
08-25-2003, 02:00 PM
I can't really see how it could be. Do you have a test page set up that we can use to test it out?

Baby Jai
08-25-2003, 02:06 PM
i will give u a username and password for testing purposes, give me a minute to testy it and upload hold on

pyro
08-25-2003, 02:09 PM
Ok, you can PM them to me, if you'd like...

Baby Jai
08-25-2003, 02:35 PM
sent it

pyro
08-25-2003, 03:48 PM
The problem seems to be that you used this format:

http://user:pass@http://www.babyjai.com/memberelite/

when you should have used:

http://user:pass@www.babyjai.com/memberelite/

Baby Jai
08-25-2003, 03:51 PM
say what? lol pyro look at that post it makes absolutel;y no sense. it you view the source it looks like that.

Baby Jai
08-25-2003, 03:54 PM
YOUR THE MAN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

pyro
08-25-2003, 03:56 PM
Make the changes in bold to your source code.

<table width="100%" border="0">
<tr>
<td width="22%" height="26"><strong><font size="2" face="Arial"><a href="http://www.babyjai.com/members/" onMouseOver="window.status=this.firstChild.data; return true" onMouseOut="window.status=''; return true">Members
Shop</a></font></strong></td>
<td width="78%"> <form action="<?php echo $PHP_SELF ?>" method="POST">
<font face="Arial">
<input type="hidden" name="server" value="www.babyjai.com/members/">
<font size="2">Username:
<input type=text name=username size=20>
Password:
<input type=password name=password size=20>
</font></font> <font face="Arial">
<input type=button value="Login!" onClick="Login(this.form)" name="button">
</font></form></td>
</tr>
<tr>
<td height="26"><strong><font size="2" face="Arial"><a href="http://www.babyjai.com/memberspremier/" onMouseOver="window.status=this.firstChild.data; return true" onMouseOut="window.status=''; return true">Premier
Members</a></font></strong></td>
<td> <form action="<?php echo $PHP_SELF ?>" method="POST">
<font face="Arial">
<input type="hidden" name="server" value="www.babyjai.com/memberspremier/">
<font size="2">Username:
<input type=text name=username size=20>
Password:
<input type=password name=password size=20>
</font></font> <font face="Arial">
<input type=button value="Login!" onClick="Login(this.form)" name="button">
</font></form></td>
</tr>
<tr>
<td height="26"><strong><font size="2" face="Arial"><a href="http://www.babyjai.com/memberelite/" onMouseOver="window.status=this.firstChild.data; return true" onMouseOut="window.status=''; return true">Elite
Members</a></font></strong></td>
<td> <form action="<?php echo $PHP_SELF ?>" method="POST">
<font face="Arial">
<input type="hidden" name="server" value="www.babyjai.com/memberelite/">
<font size="2">Username:
<input type=text name=username size=20>
Password:
<input type=password name=password size=20>
</font></font> <font face="Arial">
<input type=button value="Login!" onClick="Login(this.form)" name="button">
</font></form></td>
</tr>
</table>

pyro
08-25-2003, 03:57 PM
lol... guess you figured out what I meant, eh? :D

Baby Jai
08-25-2003, 04:00 PM
yeah cause whenyou first hit it in they were smiley faces and youhad me confused, but I got it now

pyro
08-25-2003, 04:02 PM
Ah, yes. I forgot to disable the simies. Sorry 'bout that...

Baby Jai
08-25-2003, 04:05 PM
now if you could just help me with the PHP code for sending email attachements ;)

pyro
08-25-2003, 04:06 PM
I've never done it, but I can tell you it will most likely be a pain in the butt, as you need to mess with MIME types, and that always gets complex.

Baby Jai
08-25-2003, 04:11 PM
I hear ya bro, oh by the way you wont have to be helping me out much longer, im going to Kuwait in Novemeber, but in the meantime if you could just help me out with some type of way to send a JPG thru html or whatever. Would be great and then no longer will you have to deal with me. Although I plan on purchasing a notebook so when I go to Kuwait I could still bother you

pyro
08-25-2003, 04:15 PM
Can you explain what you need? I might be able to think of a solution that will be much easier...

Do you just need a way to get people visiting your site to be able to send you images?

A notebook just so you can "bother" me. Not sure if I should feel honored or pissed... lol :D

Baby Jai
08-25-2003, 04:23 PM
Ahh, so I can bother you, tell you my daily stories, I hope your into combat stories ;), feel honored your good people. Also I was looking at the 3D Graphics, site you have on yours. Wanna build me one? Email me at webmaster@babyjai.com

pyro
08-25-2003, 04:28 PM
Emailed ya...

Baby Jai
08-26-2003, 02:54 PM
Hey pyro or someone help me out on this, whats wrong with this code? I want it to open in the mainframe, Even if I eliminate the mainframe it still shows up as an error on the page

<table width="120" border="1">
<tr>
<td height="26"><div align="center"><strong><font size="2" face="Arial">Member
Login</font></strong></div></td>
</tr>
<tr>
<td width="78%" height="103"> <form action="<?php echo $PHP_SELF ?>" method="POST">
<div align="left"><font face="Arial">
<input type="hidden" name="server" value="www.babyjai.com/members/" target="mainFrame">
<font size="2">Username:
<input type=text name=username size=20>
Password:
<input type=password name=password size=20>
</font></font> <font face="Arial">
<input type=button value="Login!" onClick="Login(this.form)" name="button">
</font></div>
</form></td>
</tr>
</table>

pyro
08-26-2003, 02:58 PM
Use your original code, and then change this line:

window.location = htsite;

to

top.mainFrame.location.href = htsite;

Baby Jai
08-26-2003, 03:02 PM
Ok check this out here (http://www.babyjai.com/index2.html) tell me whats wrong with the login box code?

pyro
08-26-2003, 03:05 PM
Pulling this code from your page:

<table width="120" border="1">
<tr>
<td height="26"><div align="center"><strong><font size="2" face="Arial">Member
Login</font></strong></div></td>
</tr>
<tr>
<td width="78%" height="103"> <form action="<?php echo $PHP_SELF ?>" method="POST">
<font face="Arial">
<input type="hidden" name="server" value="www.babyjai.com/members/">
<font size="2">Username:
<input type=text name=username size=15>
Password:
<input type=password name=password size=15>
</font></font> <font face="Arial">
<input type=button value="Login!" onClick="Login(this.form)" name="button">
</font></form></td>
</tr>
</table>

We see that #1 the PHP was not parsed in the action tag, and #2 (we don't see it here, but rather in the full source) you do not have any function on your page named Login, which is called on the button's onclick event handler.

Baby Jai
08-26-2003, 03:07 PM
ok so what do i have to do to fix those issues

Baby Jai
08-26-2003, 03:10 PM
ok I see this is what I need to add

<?php
$username = $_POST['username'];
$password = $_POST['password'];
$server = $_POST['server'];
$htsite = "http://" . $username . ":" . $password . "@" . $server;
header("Location: $htsite");
?>

Baby Jai
08-26-2003, 03:14 PM
so what do i do to fix that so it goes to the mainframe?

pyro
08-26-2003, 03:18 PM
Add target="mainFrame" to your <form> tag.

Baby Jai
08-26-2003, 03:29 PM
nope no good, the minute you hit login, it tells you an error on the page. Try it out, you will see what i mean, you can just enter anything

pyro
08-26-2003, 03:40 PM
The logic seems to be all messed up. On your left frame page, just add a simple form, that has it's action set to a PHP page. Also, add target="mainFrame" to the <form> tag.

Now, in the PHP page that you link to, add this code:

<?php
$username = $_POST['username'];
$password = $_POST['password'];
$server = $_POST['server'];
$htsite = "http://" . $username . ":" . $password . "@" . $server;
header("Location: $htsite");
?>Note that the header redirect might (read, probably will) redirect the entire page, if so, you might be out of luck with the PHP version of logging in with .htaccess...

Baby Jai
08-26-2003, 03:46 PM
ok check it out, i had the original linked to a html page, with no problems the one you tyested and we got it to work. Why would I have ot change that to a PHP page, why doesnt it work the way we had it? if you go here (http://www.babyjai.com/members.html) it works great with the same code. I cant understand it. There should be no diffrence just making it go to a diffrent frame.

pyro
08-26-2003, 03:49 PM
The first time, you used javascript, this time, it looks like you are trying to do it with PHP. PHP and frames don't like each other. Pyro and frames also don't like each other... ;)

Baby Jai
08-26-2003, 03:54 PM
Oh my, I got it, now the only problem is it will not open in the other frame. What can we do pyro?

pyro
08-26-2003, 03:56 PM
The only thing I can think of (besides not using frames... ;)) is to go back to the JavaScript method...

Baby Jai
08-26-2003, 03:57 PM
yes but it has something to do with the location.$htsite? No? Well do you have a cle what we can do to make it open in the other frame?

pyro
08-26-2003, 03:58 PM
Yes, the PHP header("Location:...") will automatically break the page out of frames.

Baby Jai
08-26-2003, 04:00 PM
Bang! I got it, I just fixed the window.location that you told me before, in the HEADER that i didnt add that was cuasing the problem! Your the man

pyro
08-26-2003, 04:06 PM
Sweet, glad we got it...

Baby Jai
08-26-2003, 04:12 PM
About time huh.....check it out tell me what you think:)

pyro
08-26-2003, 04:17 PM
Looks like it's working well...

Baby Jai
09-20-2003, 04:35 PM
<SCRIPT LANGUAGE="JavaScript">

<!-- Based on FTP log in by: Reinout Verkerk -->
<!-- Original: Gordon Hudson (sales@hostroute.com) -->
<!-- Web Site: http://www.hostroute.com/ -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function Login(form) {
var username = form.username.value;
var password = form.password.value;
var server = form.server.value;
if (username && password && server) {
var htsite = "http://" + username + ":" + password + "@" + server;
window.location = htsite;
}
else {
alert("Please enter your username and password.");
}
}
// End -->
</script>

tellme waht is wrong this code. Pyro, it tells me object is expected but it willnot load the site why? you dont need a username and pass to see, tell me what you thinnk

pyro
09-20-2003, 04:50 PM
Does it tell you which line, or do you have a link?

Baby Jai
09-20-2003, 04:54 PM
its here in the login box, and it says object expected just view the source and tell me whats wronghere (http://www.babyjai.com)

Baby Jai
09-20-2003, 08:06 PM
ok i got it to work, how do i set it up so it opens in a new window not over the old one.

pyro
09-20-2003, 08:15 PM
Change this part:

window.location = htsite;

to:

window.open(htsite);

Baby Jai
09-21-2003, 10:39 AM
thanks again pyro

pyro
09-21-2003, 12:47 PM
You bet... :)

Baby Jai
09-21-2003, 04:54 PM
Welp, now we are going to back here buddy. How do i open this jammy in the iframe???

pyro
09-21-2003, 04:57 PM
If you are using javascript, try:

top.iframename.location.href = htsite;