9 Replies - 3691 Views - Last Post: 30 December 2008 - 01:00 PM Rate Topic: -----

#1 chris_s_22  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 74
  • Joined: 27-December 08

creating a login/register facility on my site

Posted 27 December 2008 - 10:30 AM

I am trying to add a login/register facility to my site i have very limited knowledge on php and mysql.

my site is pinkangel4u.com yes i am working in the adult industry so please i can do without any remarks as such im here for help

my aim is to have

a login facilty with username and password feilds, with a forgot password facility,

a register facility with the following feilds
nickname
password
confirm password
email address - verify email
date of birth - must be over 18
country

id like it so people can logout facility, i want people to only have a login time of 2 hours so after the time expires they have to re login also if possible if a usser is idle for more than 30mins then they would be automatically logout

once logged in i want people to be able to edit there ptofiles but with more feilds than mentioned above

Is This A Good Question/Topic? 0
  • +

Replies To: creating a login/register facility on my site

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4187
  • View blog
  • Posts: 11,845
  • Joined: 18-April 07

Re: creating a login/register facility on my site

Posted 27 December 2008 - 11:03 AM

The topic you will want to lookup is called PHP "sessions". PHP comes with a set of functions that are used to control a session that a user has on your site. A session keeps track of the user throughout their time on the site and is created when they first login and identify themselves and ends when either you destroy the session or the session times out after a predetermined time.

Sessions can store data, any data that you want really, and is the best way to make sure that a user is logged in to access pages.

The trick goes that when they fill in the sign-in form and hit login you will look up the username and password they provided in the database, verify who they are, then create a session. The first variable you will put in this session is something like $_SESSION["auth"] = true. This is simple variable we created called "auth" which will hold the value "true". Then on each page of your site you simply check if "auth" is first set and if so that its value is "true". If this ever fails, you force them to re-sign in. When they hit logout you call session_destroy() on their session and send them back to the login page to re-sign back in.

So read up on that topic at php.net and I believe they even have some examples of how sessions work. Then look up online a login session tutorial and I can guarantee that you will find all the code you need to create a login/logout script using sessions. :)
Was This Post Helpful? 0
  • +
  • -

#3 chris_s_22  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 74
  • Joined: 27-December 08

Re: creating a login/register facility on my site

Posted 27 December 2008 - 11:51 AM

i have read a lot of articles on creating exactly what i want, im in need of someone going through it with me step by step, i have a very limited knowledge so looking for someone with spare time and patience.

im not wanting a ready made script though would be better than nothing at all but i am hear to learn the process from a willing teacher

at first i had a guy who gave me a link to a site with step by step instructions i made all the .php pages but i kept getting errors and not to work at all the only thing i got to work was that i created a database, i created a table then after that nothing worked like it was suposed to.

so please people help a girl in distress
if you prefer to go through it with me on my msn addy let me know
Was This Post Helpful? 0
  • +
  • -

#4 sam_benne  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 16
  • View blog
  • Posts: 732
  • Joined: 16-January 08

Re: creating a login/register facility on my site

Posted 27 December 2008 - 12:07 PM

Hi My name is Sam I have created a working login script, with registration and forget password. It also has an acvtivation script that sends an email that you have to use to login. If you wnat I can help you create your own. If you like add my MSN and talk to me on there. sam_benne@hotmail.co.uk

This post has been edited by sam_benne: 27 December 2008 - 12:07 PM

Was This Post Helpful? 0
  • +
  • -

#5 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4187
  • View blog
  • Posts: 11,845
  • Joined: 18-April 07

Re: creating a login/register facility on my site

Posted 27 December 2008 - 12:17 PM

View Postchris_s_22, on 27 Dec, 2008 - 10:51 AM, said:

i have read a lot of articles on creating exactly what i want, im in need of someone going through it with me step by step, i have a very limited knowledge so looking for someone with spare time and patience.

im not wanting a ready made script though would be better than nothing at all but i am hear to learn the process from a willing teacher

at first i had a guy who gave me a link to a site with step by step instructions i made all the .php pages but i kept getting errors and not to work at all the only thing i got to work was that i created a database, i created a table then after that nothing worked like it was suposed to.

so please people help a girl in distress
if you prefer to go through it with me on my msn addy let me know



Well we are not able to give personal tutoring just because of the volume we handle every day. You would be at the end of a very long line. But if you are working on a project and then start having errors, that is when you are suppose to come here and post what is giving you the problem.

We specialize in working through a problem with you when you are stuck. Just long enough to get you unstuck.

:)
Was This Post Helpful? 0
  • +
  • -

#6 chris_s_22  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 74
  • Joined: 27-December 08

Re: creating a login/register facility on my site

Posted 27 December 2008 - 12:33 PM

ok i totally understand Martyr2 ok well my first error problem is that when i create a data base i try creating a table i get the following error

#1067 - Invalid default value for 'id'

CREATE TABLE users (
id int(10) DEFAULT '0' NOT NULL auto_increment, 
username varchar(40),
password varchar(50), 
regdate varchar(20),
email varchar(100),
website varchar(150),
location varchar(150),
show_email int(2) DEFAULT '0',
last_login varchar(20),
PRIMARY KEY(id))


Was This Post Helpful? 0
  • +
  • -

#7 chris_s_22  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 74
  • Joined: 27-December 08

Re: creating a login/register facility on my site

Posted 27 December 2008 - 12:56 PM

ok i seem to have fixed that was i right by taking out the DEFAULT '0' ?


my next problem is that i when i register a message comes up with

Warning: preg_match() [function.preg-match]: Unknown modifier '/' in /mounted-storage/home74b/sub009/sc42562-IQUU/www/Login/register.php on line 73

Registered
Thank you, your information has been added to the database, you may now log in.

though all the details i used in the login script in ables me to login fine.

heres the code i am using

<?php
require('db_connect.php');	// database connect script.
?>

<html>
<head>
<title>Register an Account</title>
</head>
<body>

<?php

if (isset($_POST['submit'])) { // if form has been submitted
	/* check they filled in what they supposed to, 
	passwords matched, username
	isn't already taken, etc. */

	if (!$_POST['uname'] || !$_POST['passwd'] ||
		!$_POST['passwd_again'] || !$_POST['email']) {
		die('You did not fill in a required field.');
	}

	// check if username exists in database.

	if (!get_magic_quotes_gpc()) {
		$_POST['uname'] = addslashes($_POST['uname']);
	}

	$qry = "SELECT username FROM users WHERE username = '".$_POST['uname']."'";
	$name_check = $db_object->query($qry);

	if (DB::isError($name_check)) {
		die($name_check->getMessage());
	}

	$name_checkk = $name_check->numRows();

	if ($name_checkk != 0) {
		die('Sorry, the username: <strong>'.$_POST['uname'].'</strong>'
		  . ' is already taken, please pick another one.');
	}

	// check passwords match

	if ($_POST['passwd'] != $_POST['passwd_again']) {
		die('Passwords did not match.');
	}

	// check e-mail format

	if (!preg_match("/.*@.*..*/", $_POST['email']) ||
		 preg_match("/(<|>)/", $_POST['email'])) {
		die('Invalid e-mail address.');
	}

	// no HTML tags in username, website, location, password

	$_POST['uname'] = strip_tags($_POST['uname']);
	$_POST['passwd'] = strip_tags($_POST['passwd']);
	$_POST['website'] = strip_tags($_POST['website']);
	$_POST['location'] = strip_tags($_POST['location']);

	// check show_email data

	if ($_POST['show_email'] != 0 & $_POST['show_email'] != 1) {
		die('Nope');
	}

	/* the rest of the information is optional, the only thing we need to 
	check is if they submitted a website, 
	and if so, check the format is ok. */

	if ($_POST['website'] != '' & !preg_match("/^(http|ftp):///", $_POST['website'])) {
		$_POST['website'] = 'http://'.$_POST['website'];
	}

	// now we can add them to the database.
	// encrypt password

	$_POST['passwd'] = md5($_POST['passwd']);

	if (!get_magic_quotes_gpc()) {
		$_POST['passwd'] = addslashes($_POST['passwd']);
		$_POST['email'] = addslashes($_POST['email']);
		$_POST['website'] = addslashes($_POST['website']);
		$_POST['location'] = addslashes($_POST['location']);
	}

	$regdate = date('m d, Y');

	$insert = "INSERT INTO users (
			username, 
			password, 
			regdate, 
			email, 
			website, 
			location, 
			show_email, 
			last_login) 
			VALUES (
			'".$_POST['uname']."', 
			'".$_POST['passwd']."', 
			'$regdate', 
			'".$_POST['email']."', 
			'".$_POST['website']."', 
			'".$_POST['location']."', 
			'".$_POST['show_email']."', 
			'Never')";

	$add_member = $db_object->query($insert);

	if (DB::isError($add_member)) {
		die($add_member->getMessage());
	}

	$db_object->disconnect();
?>

<h1>Registered</h1>

<p>Thank you, your information has been added to the database, 
you may now <a href="login.php" title="Login">log in</a>.</p>

<?php

} else {	// if form hasn't been submitted

?>
<h1>Register</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table align="center" border="1" cellspacing="0" cellpadding="3">
<tr><td>Username*:</td><td>
<input type="text" name="uname" maxlength="40">
</td></tr>
<tr><td>Password*:</td><td>
<input type="password" name="passwd" maxlength="50">
</td></tr>
<tr><td>Confirm Password*:</td><td>
<input type="password" name="passwd_again" maxlength="50">
</td></tr>
<tr><td>E-Mail*:</td><td>
<input type="text" name="email" maxlength="100">
</td></tr>
<tr><td>Website:</td><td>
<input type="text" name="website" maxlength="150">
</td></tr>
<tr><td>Location</td><td>
<input type="text" name="location" maxlength="150">
</td></tr>
<tr><td>Show E-Mail?</td><td>
<select name="show_email">
<option value="1" selected="selected">Yes</option>
<option value="0">No</option></select>
</td></tr>
<tr><td colspan="2" align="right">
<input type="submit" name="submit" value="Sign Up">
</td></tr>
</table>
</form>

<?php

}

?>
</body>
</html>


Was This Post Helpful? 0
  • +
  • -

#8 sam_benne  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 16
  • View blog
  • Posts: 732
  • Joined: 16-January 08

Re: creating a login/register facility on my site

Posted 27 December 2008 - 02:15 PM

Try this;

<?php
require('db_connect.php');	// database connect script.
?>

<html>
<head>
<title>Register an Account</title>
</head>
<body>

<?php

if (isset($_POST['submit'])) { // if form has been submitted
	/* check they filled in what they supposed to,
	passwords matched, username
	isn't already taken, etc. */

	if (!$_POST['uname'] || !$_POST['passwd'] ||
		!$_POST['passwd_again'] || !$_POST['email']) {
		die('You did not fill in a required field.');
	}

	// check if username exists in database.

	if (!get_magic_quotes_gpc()) {
		$_POST['uname'] = addslashes($_POST['uname']);
	}

	$qry = "SELECT username FROM users WHERE username = '".$_POST['uname']."'";
	$name_check = $db_object->query($qry);

	if (DB::isError($name_check)) {
		die($name_check->getMessage());
	}

	$name_checkk = $name_check->numRows();

	if ($name_checkk != 0) {
		die('Sorry, the username: <strong>'.$_POST['uname'].'</strong>'
		  . ' is already taken, please pick another one.');
	}

	// check passwords match

	if ($_POST['passwd'] != $_POST['passwd_again']) {
		die('Passwords did not match.');
	}

	// check e-mail format

	if (!preg_match("/.*@.*..*/", $_POST['email']) ||
		 preg_match("/(<|>)/", $_POST['email'])) {
		die('Invalid e-mail address.');
	}

	// no HTML tags in username, website, location, password

	$_POST['uname'] = strip_tags($_POST['uname']);
	$_POST['passwd'] = strip_tags($_POST['passwd']);
	$_POST['website'] = strip_tags($_POST['website']);
	$_POST['location'] = strip_tags($_POST['location']);

	// check show_email data

	if ($_POST['show_email'] != 0 & $_POST['show_email'] != 1) {
		die('Nope');
	}

	/* the rest of the information is optional, the only thing we need to
	check is if they submitted a website,
	and if so, check the format is ok. */

	if ($_POST['website'] != '' && !preg_match("/^(http|ftp):///", $_POST['website'])) {
		$_POST['website'] = 'http://'.$_POST['website'];
	}

	// now we can add them to the database.
	// encrypt password

	$_POST['passwd'] = md5($_POST['passwd']);

	if (!get_magic_quotes_gpc()) {
		$_POST['passwd'] = addslashes($_POST['passwd']);
		$_POST['email'] = addslashes($_POST['email']);
		$_POST['website'] = addslashes($_POST['website']);
		$_POST['location'] = addslashes($_POST['location']);
	}

	$regdate = date('m d, Y');

	$insert = "INSERT INTO users (
			`username`,
			`password`,
			`regdate`,
			`email`,
			`website`,
			`location`,
			`show_email`,
			`last_login`)
			VALUES (
			'".$_POST['uname']."',
			'".$_POST['passwd']."',
			'$regdate',
			'".$_POST['email']."',
			'".$_POST['website']."',
			'".$_POST['location']."',
			'".$_POST['show_email']."',
			'Never')";

	$add_member = $db_object->query($insert);

	if (DB::isError($add_member)) {
		die($add_member->getMessage());
	}

	$db_object->disconnect();
?>

<h1>Registered</h1>

<p>Thank you, your information has been added to the database,
you may now <a href="login.php" title="Login">log in</a>.</p>

<?php

} else {	// if form hasn't been submitted

?>
<h1>Register</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table align="center" border="1" cellspacing="0" cellpadding="3">
<tr><td>Username*:</td><td>
<input type="text" name="uname" maxlength="40">
</td></tr>
<tr><td>Password*:</td><td>
<input type="password" name="passwd" maxlength="50">
</td></tr>
<tr><td>Confirm Password*:</td><td>
<input type="password" name="passwd_again" maxlength="50">
</td></tr>
<tr><td>E-Mail*:</td><td>
<input type="text" name="email" maxlength="100">
</td></tr>
<tr><td>Website:</td><td>
<input type="text" name="website" maxlength="150">
</td></tr>
<tr><td>Location</td><td>
<input type="text" name="location" maxlength="150">
</td></tr>
<tr><td>Show E-Mail?</td><td>
<select name="show_email">
<option value="1" selected="selected">Yes</option>
<option value="0">No</option></select>
</td></tr>
<tr><td colspan="2" align="right">
<input type="submit" name="submit" value="Sign Up">
</td></tr>
</table>
</form>

<?php

}

?>
</body>
</html>


Was This Post Helpful? 0
  • +
  • -

#9 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 89
  • View blog
  • Posts: 796
  • Joined: 25-February 08

Re: creating a login/register facility on my site

Posted 27 December 2008 - 10:47 PM

Hey there,

Just wanted to let you know that if you aren't familiar with PHP and MySQL, you may want to consider hiring somebody to do the leg work for you. There are a lot of security issues to take into account when you're building a website, and it sounds like you could use some guidance. That's not to mention proper database design and creating a site that will be able to hold the amount of users you want on the site. Also you'll need to plan everything around your payment processing service as well.

I'm available for consulting or freelance work if you're interested in hiring someone. If you're just looking for someone to walk you through step by step I could provide consulting services, or if you're looking to hire someone to build the site I could help you with that as well.

PM me if you're interested and I can give you references, examples, rates, etc.

Take care and good luck.

Andrew
Was This Post Helpful? 0
  • +
  • -

#10 chris_s_22  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 74
  • Joined: 27-December 08

Re: creating a login/register facility on my site

Posted 30 December 2008 - 01:00 PM

View Postakozlik, on 27 Dec, 2008 - 09:47 PM, said:

Hey there,

Just wanted to let you know that if you aren't familiar with PHP and MySQL, you may want to consider hiring somebody to do the leg work for you. There are a lot of security issues to take into account when you're building a website, and it sounds like you could use some guidance. That's not to mention proper database design and creating a site that will be able to hold the amount of users you want on the site. Also you'll need to plan everything around your payment processing service as well.

I'm available for consulting or freelance work if you're interested in hiring someone. If you're just looking for someone to walk you through step by step I could provide consulting services, or if you're looking to hire someone to build the site I could help you with that as well.

PM me if you're interested and I can give you references, examples, rates, etc.

Take care and good luck.

Andrew



email me need all the hewlp i can get
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1