Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-26-2005, 05:11 PM   #1
Dailydiapers
Confirmed User
 
Dailydiapers's Avatar
 
Industry Role:
Join Date: Oct 2003
Location: USA
Posts: 1,079
Dumb question: making a login box

Okay, forgive the dumb noob question, but i'm a self-taught webmaster and just don't know some things ya'll think are simple

I'm redesigning one of my sites that's a combination of free and pay services. On the fre side I want to put a login box for the protected directory, rather than using the pop-up login box you get when you link directly to the protected directory. Can someone tell me how to write (or give me a template) the code for the login box?
__________________
Mike
http://www.dailydiapers.com/
Dailydiapers is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-26-2005, 05:16 PM   #2
ssp
Confirmed User
 
Join Date: Jan 2005
Location: United Kingdom
Posts: 7,990
Use PHP and lookup an online tutorial on how to do this. There are loads and loads around which help you make one step by step.
ssp is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-26-2005, 05:17 PM   #3
Fake Nick
So Fucking Banned
 
Join Date: Jul 2004
Location: go troll goo!
Posts: 7,708
http://www.gofuckyourself.com/showthread.php?t=437375
Fake Nick is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-26-2005, 06:53 PM   #4
Dailydiapers
Confirmed User
 
Dailydiapers's Avatar
 
Industry Role:
Join Date: Oct 2003
Location: USA
Posts: 1,079
PHP is one of those dumbfounded area for me, looking to include it (log-in box) in a straight HTML design.
__________________
Mike
http://www.dailydiapers.com/
Dailydiapers is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-26-2005, 07:07 PM   #5
calmlikeabomb
Confirmed User
 
calmlikeabomb's Avatar
 
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
Use php and sql

Your login form:
Code:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method=p.ost>

Username: <input type="text" name="username" maxlength="20" />
Password:<input type="password" name="password" maxlength="20" />
<input type="submit" name="submit" value="Login">

</form>
If this form is submitted check for user in database set cookies and redirect.
Code:
<?php

// Create a function for escaping the data.
	function escape_data ($data) {
		global $dbc; // Need the connection.
		if (ini_get('magic_quotes_gpc')) {
			$data = stripslashes($data);
		}
		return mysql_real_escape_string($data, $dbc);
} // End of function.

if (isset($_POST['submit'])) { // Check if the form has been submitted.

	require_once ('../mysql_connect.php'); // Connect to the database.
	
	if (empty($_POST['username'])) { // Validate the username.
		$u = FALSE;
		echo '<p><font color="red" >You forgot to enter your username!</font></p>';
	} else {
		$u = escape_data($_POST['username']);
	}
	
	if (empty($_POST['password'])) { // Validate the password.
		$p = FALSE;
		echo '<p><font color="red" >You forgot to enter your password!</font></p>';
	} else {
		$p = escape_data($_POST['password']);
	}
	
	if ($u && $p) { // If everything's OK.
	
		// Query the database.
		$query = "SELECT customer_id, firstname FROM customers WHERE username='$u' AND password=PASSWORD('$p')";		
		$result = @mysql_query ($query);
		$row = mysql_fetch_array ($result, MYSQL_NUM); 
		
		if ($row) { // A match was made.
				
				// Start the session, register the values & redirect.
				setcookie ('user_id', $row[0], time()+2419200, '/', '', 0);
				header ("Location:  http://www.domain.com/index.php");
				ob_end_flush(); // Delete the buffer.
				exit();
				
		} else { // No match was made.
			echo '<p><font color="red" >The username and password entered do not match those on file.</font></p>'; 
		}
		
		mysql_close(); // Close the database connection.
		
	} else { // If everything wasn't OK.
		echo '<p><font color="red" >Please try again.</font></p>';		
	}
	
} // End of SUBMIT conditional.
Protect pages with something like this:
Code:
<?php
if (!isset($_COOKIE['user_id'])) {
	header ("Location:  http://www.domain.com/login.php");
	}
?>
You'll also need a form to register your users to the database.


Dumbass
__________________
subarus.
calmlikeabomb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-26-2005, 07:10 PM   #6
ssp
Confirmed User
 
Join Date: Jan 2005
Location: United Kingdom
Posts: 7,990
Quote:
Originally Posted by Dailydiapers
PHP is one of those dumbfounded area for me, looking to include it (log-in box) in a straight HTML design.
Creating a login box wont be difficult. But you need some kind of dynamics to process whats submitted. Either Perl, PHP, ASP.
ssp is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-26-2005, 07:13 PM   #7
stevo
Confirmed User
 
Join Date: Aug 2002
Location: Orlando, Florida
Posts: 2,051
Can you have PHP read a .htpasswd file? Or does it have to read from its own database?
stevo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.