x10Hosting Forums

Corporate Free Hosting for the Masses.



Register

Reply
 
LinkBack Thread Tools Display Modes
x10Hosting Member

Join Date: Sep 2008
Posts: 12
Credits: 306
sweet92 is on a distinguished road
Location: United Kingdom

Quote  
10-07-2008, 10:20 AM
Unhappy Make Login Page

could somebody help me, i want to make a login page for my site but i dont know where to start, im using dreamweaver to build this login page, i know there has to be database and the page checks the details against this database but how do you create and add data to this database and get the login page to work
Reply With Quote
sweet92 is offlineReport Post
x10 Sophmore

xmakina's Avatar

Join Date: May 2008
Posts: 236
Credits: 2,064
xmakina will become famous soon enough
Location: England

Send a message via MSN to xmakina
Quote  
10-07-2008, 10:35 AM
Re: Make Login Page

Oh FFS learn to google.

Google'd for make login page and the First - *FIRST* - link was http://www.adesdesign.net/php/tutori...cure_login.php, which is exactly the tool you are using for the problem you have.

I facepalmed so hard I gave myself a concussion.
__________________
IF($this->$post.content() == "SEE SIG"){
w3Schools and Google
}
Reply With Quote
xmakina is offlineReport Post
x10Hosting Member

Join Date: Sep 2008
Posts: 12
Credits: 306
sweet92 is on a distinguished road
Location: United Kingdom

Quote  
10-07-2008, 10:43 AM
Re: Make Login Page

well sorry! theres no need to be rude and btw i already DO know how to google im not thick!
also i have already tried a tutorial it didnt work so i thought id ask here instead

Last edited by sweet92; 10-07-2008 at 10:46 AM.
Reply With Quote
sweet92 is offlineReport Post
x10 Sophmore

Salvatos's Avatar

Join Date: Jun 2006
Posts: 226
Credits: 2,052
Salvatos has a spectacular aura about
Location: Québec, Canada

Quote  
10-07-2008, 11:13 AM
Re: Make Login Page

Just tell us what didn't work and we'll work from there. Post the code you already have so we can see what needs to be added or changed.
Reply With Quote
Salvatos is offlineReport Post
x10Hosting Member

Join Date: Sep 2008
Posts: 12
Credits: 306
sweet92 is on a distinguished road
Location: United Kingdom

Quote  
10-07-2008, 01:05 PM
Re: Make Login Page

firstly i made the file loginpage.php , not sure if the code is important for this bit but ill add just in case
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

then i tried to make checklogin.php, i think this is where i went wrong and i got confused, the code i tried to use was this, the code is from the tutorial i tried and failed on

<?php
$host="fashion.x10hosting"; // Host name
$username=""; // Mysql username <<Unsure about this bit
$password=""; // Mysql password
$db_name="Accountinfo"; // Database name
$tbl_name=""; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>

and i didnt really get much further than that i have made the database and loginsuccess.php, im pretty new to scripts so not very sure about if i need to edit any bits
Reply With Quote
sweet92 is offlineReport Post
x10 Lieutenant

freecrm's Avatar

Join Date: May 2008
Posts: 270
Credits: 946
freecrm will become famous soon enough
Location: UK

Quote  
10-07-2008, 03:34 PM
Re: Make Login Page

Quote:
Originally Posted by sweet92 View Post
firstly i made the file loginpage.php , not sure if the code is important for this bit but ill add just in case
no problems with the form.
Quote:
Originally Posted by sweet92 View Post

then i tried to make checklogin.php
Why not keep the code in the same page as the form?
Quote:
Originally Posted by sweet92 View Post
PHP Code:
$username=""// Mysql username <<Unsure about this bit 
username is usually a mixture of your main account name and your db username (yourmainusername_databaseusername)

Quote:
Originally Posted by sweet92 View Post
PHP Code:
// Connect to server and select databse.
mysql_connect("$host""$username""$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB"); 
Try to use the MySQL error function wherever possible - it will help you loads...

PHP Code:
or die(mysql_error()) 
Try getting the connection first...

There are a few people on here that will try to help as much as possible (for some strange reason! )
__________________
Rich

If you liked this post, please give me +rep or donate credits.

My Site:
Reply With Quote
freecrm is offlineReport Post
Lord Of The Keys

Zenax's Avatar

Join Date: Jul 2006
Posts: 1,253
Credits: 5,745
Zenax will become famous soon enough
Location: The Brilliant United Kingdom

Quote  
10-07-2008, 05:23 PM
Re: Make Login Page

freecrm has already clarified most of the things required to make a login page.

The first thing that you need to do is create a Login screen. You can do this either using the design view or the code view of dreamweaver. Once you have this, then you are ready to add in the PHP code needed to make the login work.

The first thing to do is to make a database that is going to contain the login information. This is done by running SQL commands in MySQL under the cPanel belonging to your account.

Code:
CREATE TABLE users (ID MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY, username VARCHAR(60), password VARCHAR(60))
This is only a basic SQL statement that you could use. If you want extra fields on your registration form then you need to add extra fields into your database.

The next part of the build is to build a registration form to enable you to enter information into the database, that you can then use to login with.

The only fields you are going to need are a username one and a password field.

Code:
<input type="text" name="user" />
<br />
<input type="password" name="password" />
<br />
<input type="button" name="submit" value="Register!" />
That code above creates a simple basic register form. You need to include the registration code that you are going to add in a seperate page.

register.php

First the connection:
PHP Code:
$db[user] = "cPanel username here";
$db[pass] = "cpanel password here";
$db[host] = "localhost";
$db[dbname] = "name of database. Normally begins with your cPanel name";

$db_conn mysql_connect("$db[host]""$db[user]""$db[pass]")or die("cannot connect"); 

$db_select mysql_select_db("$db[dbname]")or die("cannot select DB"); 
That creates the connection to the database and then shows any erros if there are any when you are connecting to your database.

Now you have to add an insert statement into the register.php file in order to get the information that has been entered into the form into the database.

Now I aint very good with PHP so you shall have to serach google onto how to insert statements with sql using variables.

You can add extra features to the register.php file in order to make the registration more secure, such as md5 hash encryption. This is really useful on things such as passwords etc.

In the login page you need to add code to match the the entered info with that in the database!

Again me not being good with PHP and a it being a long time since I created something like this, a lot of google research will be needed when creating this.

Post back if you need more help and we shall see what we can do!
__________________
Regards,
Reply With Quote
Zenax is offlineReport Post
x10 Sophmore

Join Date: Jul 2008
Posts: 144
Credits: 1,416
xav0989 is on a distinguished road
Quote  
10-07-2008, 05:55 PM
Re: Make Login Page

then to register username and password, I'd say to use
PHP Code:
$_SESSION['user']['username'] = $username;
$_SESSION['user']['password'] = $password
You might as well consider encrypting your passwords for added security.
__________________
Use a great CMS, try eaCyMS (not available now... yet!)

Pain is weakness leaving the body.
Reply With Quote
xav0989 is offlineReport Post
x10 Sophmore

natsuki's Avatar

Join Date: Sep 2008
Posts: 110
Credits: 1,305
natsuki will become famous soon enough
Quote  
10-07-2008, 08:44 PM
Re: Make Login Page

Zenax found the problem, you should use 'localhost' as hostname (if both database and files are on x10hosting).
__________________
Reply With Quote
natsuki is offlineReport Post
x10Hosting Member

Join Date: Sep 2008
Posts: 12
Credits: 306
sweet92 is on a distinguished road
Location: United Kingdom

Quote  
10-30-2008, 11:23 AM
Re: Make Login Page

thanks alot for helping me but when i put this on my site i get an warning saying it cant connect to the database have also created a bulletin board along with login page that has an warning also along the same lines, do i need to update my php to get this to work? im on the basic php at the moment.
Reply With Quote
sweet92 is offlineReport Post
Reply

Tags
database, login

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
page login help delon Programming Help 2 05-23-2008 05:16 AM
Can't login to x10 home page or cpanel pcadmin Free Hosting 2 05-01-2008 02:11 PM
make money placing links on websites/blogs/forums/newsgroups/ figu120 Earning Money 1 03-06-2008 07:15 AM
make money placing links on websites/blogs/forums/newsgroups/... figu120 Off Topic 0 03-05-2008 09:30 PM
Page gone, login to ftp bounces musoc Free Hosting 1 11-19-2007 07:55 PM


All times are GMT -5. The time now is 09:01 AM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC7
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

Free Advertising | Loans | Car Finance | Payday Loans | Gas Suppliers