Login form on my home page?

jdlitson

Verified User
Joined
May 29, 2003
Messages
261
Hi, How can I add a login form to my home page?

Not a link to the login popup box, but the ability to type the user name and password directly on to the web page?

Here is the latest working code so you don't have to hunt for it.

Code:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Direct Admin Login</title>
</head>

<body>
<form method="POST" action="http://yourdoman.com:2222/CMD_LOGIN">
<input type="text" name="username"/>
<input type="password" name="password" size="20"/>
 <input type="submit" value="go" name="submit"/>

</form>
</body>
</html>

Thanks for your time and help -Jason

BTW I highly recomend Direct Admin.
I like many others have spent months deciding on which CP to use. DA Rocks! :D
 
Last edited:
This is just a sample way to do it with JavaScript..

You'll need to modify the HTML to make it look how you want..

Code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript"> 
<!-- Begin 
function Login(form) { 
var username = form.username.value; 
var password = form.password.value; 
var server = form.server.value; 
if (username && password && server) { 
var dalogin = "http://" + username + ":" + password + "@" + server + ":2222/"; 
window.location = dalogin; 
} 
else { 
alert("Please enter a Username and password."); 
} 
} 
// End --> 
</script>
</head>

<body bgcolor="#FFFFFF">
<form name=login>
  <div align="center">
    <table border=1 cellpadding=3>
      <tr> 
        <td colspan=2 align=center> 
          <h2 align="center">DirectAdmin Login</h2>
        </td>
      </tr>
      <tr> 
        <td>Username:</td>
        <td> 
          <input type=text name=username size=15 maxlength="26">
        </td>
      </tr>
      <tr> 
        <td>Password:</td>
        <td> 
          <input type=password name=password size=15>
        </td>
      </tr>
      <tr> 
        <td>Domain:</td>
        <td> 
<input type="text" name="server" maxlength="65" size="15">
        </td>
      </tr>
      <tr> 
        <td colspan=2 align=center> 
          <input type=button value="Login!" onClick="Login(this.form)" name="button">
        </td>
      </tr>
    </table>
  </div>
</form>
</body>
</html>
 
What I Learned

Thanks so much Prohacker. You Rock and the script works perfect!


Some mistakes I made and things I learned when using this script which I hope will help others.

1. On this line I tried typing in my domain name or IP address in the "http://" area; don't do this, just leave the entire line the way it is. Like Prohacker said is all you have to do is change the html to suite your look and feel.
var dalogin = "http://" + username + ":" + password + "@" + server + ":2222/";

2. If you would like to create a form which alows a demo user to login just by clicking the login button then modify these lines.

input type="text" name="username" size="15" maxlength="26" value="demo_user"

input type="password" name="password" size="15" value="demo"

input type="text" name="server" maxlength="65" size="15" value="Insert Your IP Address Here"

Thanks again for your help Prohacker -Jdlitson :D
 
If you are using this for a demo user to login.. You might change the server field from text to hidden as a guest doesn't need to see your server name :D
 
If it is for a demo user why even bother with a form? Why not make the URL and set it as a link i.e. if user was demo and password demo it would be:
< a href = "http://demo:[email protected]:2222/" > Login To Demo Control Panel </ a >

Of course remove spaces to get it working and replace with your IP ;)
 
SH-Lloyd said:
If it is for a demo user why even bother with a form? Why not make the URL and set it as a link i.e. if user was demo and password demo it would be:
< a href = "http://demo:[email protected]:2222/" > Login To Demo Control Panel </ a >

Of course remove spaces to get it working and replace with your IP ;)


You might just want to present it to the user as if they were a regular customer and use the login form... :D

I dunno.. People do strange things :D
 
Alternate image for submit button

Hi, Does anyone know the code to use an alternate image other than the default login image that is displayed with this script?

I tried using html 3 and html 4 using an online tutorial but was only able to get the alternate image to apear but not submit the form properly.

Thanks for your help -Jason
 
to use an image instaed of the grey box chnage the line:

<input type=button value="Login!" onClick="Login(this.form)" name="button">


to

<input name="submit" type="image" value="Login!" src="http://url.to/image.ext" onClick="Login(this.form)" alt="alt_text">


you will need to chnage "http://url.to/image.ext to the address of your image, can be local if wanted. Also, chnage your alt_text, unless you want people to get that message hovering over the submit button ;)

Chris
 
Thanks so much Chris!
I struggled with this problem for hours last night.

Best Regards -Jason :D
 
Hi Chris,
I just tried the button change code but it's not working properly.
The image does show up but the form still doesn't login.

Thanks for trying though -Jason
 
weird.... any errors? does the form go to the correct place etc?
 
The form removes the login text and stays on the same page but does not report any errors.
Does it work for you?
 
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
<!-- Begin
function Login(form) {
var username = form.username.value;
var password = form.password.value;
var server = form.server.value;
if (username && password && server) {
var dalogin = "http://" + username + ":" + password + "@" + server + ":2222/";
window.location = dalogin;
}
else {
alert("Please enter a Username and password.");
}
}
// End -->
</script>
</head>

<body bgcolor="#FFFFFF">
<form name=login>
<div align="center">
<table border=1 cellpadding=3>
<tr>
<td colspan=2 align=center>
<h2 align="center">DirectAdmin Login</h2>
</td>
</tr>
<tr>
<td>Username:</td>
<td>
<input type=text name=username size=15 maxlength="26">
</td>
</tr>
<tr>
<td>Password:</td>
<td>
<input type=password name=password size=15>
</td>
</tr>
<tr>
<td>Domain:</td>
<td>
<input type="text" name="server" maxlength="65" size="15">
</td>
</tr>
<tr>
<td colspan=2 align=center>
<input type="image" src="images/login.gif" onClick='Login(this.form)' name="submit">
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
 
Ok Thanks Chris I appreciate your help :) -Jason
 
Last edited:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
<!-- Begin
function Login(form) {
var username = form.username.value;
var password = form.password.value;
var server = form.server.value;
if (username && password && server) {
var dalogin = "http://" + username + ":" + password + "@" + server + ":2222/";
window.location = dalogin;
}
else {
alert("Please enter a Username and password.");
}
}
// End -->
</script>
</head>

<body bgcolor="#FFFFFF">
<td valign="top" width="20%">
<center>
<b>User Login</b>
</center>
<br />
<form method="post">Username:<br />
<input name="username" id="username" type="text"
value="" /><br />
Password:<br />
<input name="password" id="password" type="password"
value="" /><br />
Domain Name:<br />
<input name="server" id="server" type="text"
value="" /><br />
<input type="button" value="Login!"
onclick="Login(this.form)" name="button" /></form>
</td>
<h2 align="center"> </h2>
</td>
</tr>
<tr>
<td>  </td>
</tr>
<tr>
<td colspan=2 align=center> </td>
</tr>
</table>
</div>
</form>
</body>
</html>

save as php
 
:rolleyes: thats fromCPANEL but it works i guess ;) i will still post my new idea ;)
 
gmilazzo your script works but how do we use a custom image with it? Thanks -Jason

Still looking forward to your new idea Chris.
Thanks -Jason
 
Back
Top