Click to See Complete Forum and Search --> : Script redirecting(?) question


Acert93
09-23-2003, 03:45 PM
Hello,

I am hoping someone can lead me in the right direction. I will be offering my clients an online control panel and webmail with their accounts and wanted a quick way to direct them to their accounts control panel and webmail. For example, if their domain was www.theirdomain.com their control panel would be at something akin to this:

http://www.theirdomain.com/controlpanel

I am looking for a script that will do the following: I want a small form link on my site that allows them to enter their domain name and hit 'go' and when they hit go the script would direct them to the correct page. i.e. the domain they enter would be the [wildcard] in a link like http://www.[wildcard.com]/controlpanel and preferrably have this open up in a new browser window.

Anyone know of a free script online that can accomplish this?

Thanks!

AdamBrill
09-23-2003, 04:46 PM
This could be done in either JavaScript or a server-side language, but you would be best off to do it with a server-side language, since 13% (http://www.thecounter.com/stats/2003/May/javas.php) of users have JavaScript turned off. What languages does your server support?

pyro
09-23-2003, 04:57 PM
In PHP (untested):

The login form:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="login" action="login.php" target="_blank" method="post">
<input type="text" name="domain">
<input type="submit" name="submit" value="Login">
</form>
</body>
</html>

login.php:
<?PHP
if (isset($_POST['domain'])) {
header("Location:http://www.".$_POST['domain']."/controlpanel");
}
else {
echo "
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p>You must enter a domain name.</p>
</body>
</html>
<?PHP
";
}
?>

Acert93
09-23-2003, 05:35 PM
Hello,

My server has both PHP, Perl, and SSI server side scripting.

Thanks for taking the time to assist me with this issue. :)

pyro
09-23-2003, 05:36 PM
You bet... :)

Acert93
09-24-2003, 10:35 AM
Hello :)

Thanks for the assistance. Looking good so far, but when I go to use the login it gives the following feedback error:

Parse error: parse error, unexpected T_STRING in /home/www/biblical-hebrew/login.php on line 3

For example:

http://www.biblical-hebrew.org/login.html

Input the domain biblical-hebrew.org (this is a side project I work on in my non-extent spare time...) and it should take you to http://www.biblical-hebrew.org/cgi-bin/monstercontrols

But alas I got the above error. I uploaded both files (login.html and login.php) via FTP; I was not totally sure how to do the php file so I copied your code exactly as-is into notepad and saved it as login.php (I did change the login link from /controlpanel to /cgi-bin/monstercontrols but also changed it back to double check to make sure that did not cause the error). Also, I did not change in the php code <p>You must enter a domain name.</p> because I was assuming that information was for an empty entry submission on the html form.

I really appreciate everyones help :) I am sort of new to web design and know only a little HTML and no PHP at this point, but I have really enjoyed creating my first few sites :) Again, thanks for everyones time and assistance :)

AdamBrill
09-24-2003, 10:55 AM
Untested, but try changing this:


header("Location:<a href="http://www." target="_blank">http://www.</a>".$_POST['domain']."/controlpanel");

to this:

header("Location:http://www.".$_POST['domain']."/controlpanel");

This good old forums likes to mess up the code, lol. ;)

Acert93
09-24-2003, 02:59 PM
You guys are awesome

It looks like the code issue on line 3 was resolved, but now it results:

Parse error: parse error, unexpected '<' in /home/www/biblical-hebrew/login.php on line 10

Line 10 from above is

<html>

I really appreciate the fast and insightful feedback :)

pyro
09-24-2003, 03:05 PM
I had an error in the code I posted, try this one:

<?PHP
if (isset($_POST['domain'])) {
header("Location:http://www.".$_POST['domain']."/controlpanel");
}
else {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p>You must enter a domain name.</p>
</body>
</html>
<?PHP
}
?>

Acert93
09-24-2003, 04:20 PM
Hello pyro and AdamBrill,

I loaded the new code pyro suggested and got the following error:

Parse error: parse error, unexpected '<' in /home/www/biblical-hebrew/login.php on line 10

I am not sure if this is helpful, but the below link shows the php version my account is using (php v.4.3.0):

http://www.biblical-hebrew.org/phpinfo.php

Again, I really appreciate all the hard work everyone has done on helping me with this :)

Again, the links for testing this so far are: biblical-hebrew.com/login.html and it should take you, if you put biblical-hebrew.com in the form, to http://www.biblical-hebrew.com/cgi-bin/monstercontrols

Is there more information I can provide to assist you guys? I do not want to be a hinderance to the solution, so feel free to ask :) Thanks again!

pyro
09-24-2003, 05:01 PM
The code I posted above seems to work fine for me. Are you sure you have that exact code in login.php? Maybe you could post your code for us to look at...

Acert93
09-24-2003, 06:51 PM
Thanks pyro!

I am not sure what I did wrong, but I refreshed everything I did with your code again and it works now!! I apologize for taking more of your time, I am guessing I must have done something wrong because your code does work! :)

Thank you very much for your time and effort everyone, it is much appreciated. I am not ready to move on to php or anything like that yet, but are there any books and references and/or tools that make learning and implementing php (especially in conjunction with MySQL) easier? I will do some thread searching for this info, but if anyone has a suggestion on the tip of their tongue I would be interested... also any video demos teaching Dreamweaver would be nice :) A friend is learning DW and some of the books have been difficult for him and I think seeing someone do things, like in a video, would be great for him.

Again, many thanks for the time and effort everyone gave on this :)

pyro
09-24-2003, 09:10 PM
I personally learned PHP by just using it. I used/use http://www.php.net a lot, and recommend that anyone trying to learn PHP does the same. Might also want to pick up a book on it, as some people find it easier to learn that way. I have PHP For The World Wide Web and PHP Advanced For The World Wide Web, and while I wouldn't highly recommend either, they aren't bad books...