Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 03-02-2012, 04:43 AM   #1
Baseband Member
 
Join Date: Dec 2011
Location: New Zealand
Posts: 73
Default !!HELP!! Login Box issue...

Hey Guys - haven't been on in ages (haven't really needed much help lately). Anyways, I am making a website, and I want to add an Admin Control Panel. I want this so my staff can access a password protected page and do things other views can't (view site stats, post information, talk to other admins/staff etc.). I already have a login box sorted, but I need a way to get users registered and so when they try and login, if they arn't registered it won't let them. I'm guessing I need a database to do this. I really want to just keep it really simple as I have absolutely no knowledge with mysql or whatever. Can someone please help!

Thanks,
Silvalite110
__________________

Silvalite is offline   Reply With Quote
Old 03-12-2012, 01:24 AM   #2
Daemon Poster
 
wmorri's Avatar
 
Join Date: May 2007
Posts: 1,066
Send a message via AIM to wmorri
Default Re: !!HELP!! Login Box issue...

Hi,

The first thing that I would say is that if you don't have your login connected then you don't really have login sorted. To expand a little on that I don't want it to seem like you haven't done the hard part because you have. It is just that without having a place to store your login information setting up and admin panel is not helpful to you at this time. I would start by posting the code that you have so far, and then we can work with you to figure where you need to expand.
__________________

__________________
LEARN BY DOING NOT BY FOLLOWING DIRECTIONS!
Linux Forever!

I thought you were a hispanic/african american? Who is the white guy in the pictures?
wmorri is offline   Reply With Quote
Old 03-13-2012, 02:25 AM   #3
Baseband Member
 
Join Date: Dec 2011
Location: New Zealand
Posts: 73
Default Re: !!HELP!! Login Box issue...

Hey - thanks for the reply, but thats the thing. I don't have code because I haven't started!
Silvalite is offline   Reply With Quote
Old 03-13-2012, 05:12 PM   #4
Daemon Poster
 
wmorri's Avatar
 
Join Date: May 2007
Posts: 1,066
Send a message via AIM to wmorri
Default Re: !!HELP!! Login Box issue...

Hi,

The first thing that you need to do is create a simple form. One that has all the fields that you want, name, username, email, etc. Then you will need to work on a php script to collect all that information and send it somewhere or to someone. Have a look at forms for more help with the first part.

When you finish that I can look it over for you. You can post it up here unless you are comfortable with it.
__________________
LEARN BY DOING NOT BY FOLLOWING DIRECTIONS!
Linux Forever!

I thought you were a hispanic/african american? Who is the white guy in the pictures?
wmorri is offline   Reply With Quote
Old 03-15-2012, 02:48 AM   #5
Baseband Member
 
Join Date: Dec 2011
Location: New Zealand
Posts: 73
Default Re: !!HELP!! Login Box issue...

Ok thanks for the offer but i have absolutely no PHP knowledge so I can't post the script...
Silvalite is offline   Reply With Quote
Old 03-15-2012, 06:09 PM   #6
Daemon Poster
 
wmorri's Avatar
 
Join Date: May 2007
Posts: 1,066
Send a message via AIM to wmorri
Default Re: !!HELP!! Login Box issue...

That is fine. Have a look at php form. It will give you a little beginning. If you post the code for your html form then I can have a look at it and write some php code for you.
__________________
LEARN BY DOING NOT BY FOLLOWING DIRECTIONS!
Linux Forever!

I thought you were a hispanic/african american? Who is the white guy in the pictures?
wmorri is offline   Reply With Quote
Old 03-19-2012, 11:34 PM   #7
Baseband Member
 
Join Date: Feb 2012
Location: United States
Posts: 28
Default Re: !!HELP!! Login Box issue...

If you have setup the database to store your user login info that is the first step then it is just a matter of placing a form like this

Code:
<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>
you will then need code to check the info typed

Code:
<?php
$host="localhost"; // Host name 
$username=""; // Mysql username 
$password=""; // Mysql password 
$db_name="test"; // Database name 
$tbl_name="members"; // 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";
}
?>
this is the core of the process you will then need to protect the page

Code:
<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
    header('WWW-Authenticate: Basic realm="My Realm"');
    header('HTTP/1.0 401 Unauthorized');
    echo 'Text to send if user hits Cancel button';
    exit;
} else {
    echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
    echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>";
}
?>
hope that helps

I write all my code in php pages
__________________

jlcpcnc is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off



All times are GMT -5. The time now is 01:36 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0