Viewing Topic: Member System
Sample! |
Genius |
Subject: "Member System
Sample!"
Posted: @ 1:59 am on Feb 25 2008 |
|
|
 Member #: 582 Rank: User - (77) Since: 02/18/08 Posts: 76 From: kmmk
|
Ok. I finally
got everything
working. Thanks
to bs0d for
writing the
script! This is
for people who
are still
struggling with
it. Here's what
I did:
Make header.php
and modify the
header.php to
this:
Code:
<?php
ob_start();
session_start()
;
require_once('d
b_connect.php')
;
//check cookie
if
($_SESSION['log
ged_in'] != 1
&&
isset($_COOKIE[
'login_cookie']
)) {
list($user,
$pass) =
explode('[]',
$_COOKIE['login
_cookie']);
$qu =
mysql_query(&qu
ot;SELECT
`user_password`
FROM `members`
WHERE
`username` =
'".addslas
hes($user).&quo
t;'"  ;
if
(mysql_num_rows
($qu) == 1) {
$passw
=
mysql_fetch_obj
ect($qu);
if
($passw->use
r_password ==
$pass) {
$_SESSION['logg
ed_in'] = 1;
$_SESSION['user
name'] = $user;
$_SESSION['pass
word'] = $pass;
}
}
}
if(!isset($_SES
SION['username'
]) &&
!isset($_SESSIO
N['password']))
{
$_SESSION['logg
ed_in'] = 0;
$user =
"Guest&quo
t;;
}
if(!isset($_SES
SION['username'
]) &&
!isset($_SESSIO
N['password']))
{
$_SESSION['logg
ed_in'] = 0;
$user =
"Guest&quo
t;;
$message =
"<br>
;Please <a
href=login.php&
gt;Login</a&
gt; or
<a
href=login.php&
gt;Register<
/a>
here";
}else if
($_SESSION['log
ged_in'] == 1 )
{
$user =
$_SESSION['user
name'];
$message =
"<br>
;<a
href=account.ph
p>My
Account</a&g
t;<br>
<a
href=logout.php
>Logout</
a>";
}
?>
Here's my
register.php
You will need
to change the
paths.
Code:
<?php
session_start()
;
require_once('d
b_connect.php')
;
//SEE IF
ALREADY LOGGED
IN
if($_SESSION['
logged_in'] ==
1)
{
//REDIRECT
TO HOMEPAGE
header('Locatio
n: http://' .
$_SERVER['HTTP_
HOST'] . '');
} else {
if(isset($_POS
T['submit']))
{
//BEGIN
CHECKING
USERNAME...
if(!$_POST['use
rname'])
die('Alert:
username field
was blank.');
//array of
invalid
characters
$junk =
array('.' , ','
, '/' , '\'' ,
'`' , ';' , '['
, ']' , '-',
'_', '*',
'&', '^',
'%', '$', '#',
'@', '!', '~',
'+', '(', ')',
'|', '{', '}',
'<', '>',
'?', ':',
'"', '=');
//starting
lenght of
username
$len =
strlen($_POST['
username']);
//replace
invalid
characters
$_POST['usernam
e'] =
str_replace($ju
nk, '',
$_POST['usernam
e']);
$test =
$_POST['usernam
e'];
//if lenghts
are different
($len smaller),
invalid
characters
found, so
prompt error.
if(strlen($test
) != $len) {
die('Username
Error: Username
contained
invalid
characters. You
can only use
A-Z, 0-9 and
the
underscore
(_).');
}
//Check if
username
already
exists...
$q2 =
mysql_query(&qu
ot;SELECT *
FROM `members`
WHERE
`username` =
'".$_POST[
'username'].&qu
ot;'"  ;
$q3 =
mysql_fetch_obj
ect($q2);
if($q3->user
name ==
$_POST['usernam
e']) {
die('<BR>
;<BR>Sorr
y, but the
username
"'.$q3->
;username.'&quo
t; is taken,
please choose
another.');
}
//PASSWORD
if(!$_POST['pas
sword']) {
die('Error:
Password field
was blank');
}
if(!$_POST['ver
ify_password'])
{
die('Error:
Verify Password
field was
blank.');
}
if($_POST['pass
word'] !=
$_POST['verify_
password']) {
die('Error:
The passwords
do not
match.');
}
if(strlen($_POS
T['password'])
< 6 ) {
die('Error:
Your password
is too short.
Must be 6 or
more characters
in length.');
}
//ADD NEW
MEMBER
$insert
="INSERT
INTO `members`
(username,
user_password,
user_email)
VALUES
('".$_POST
['username'].&q
uot;',
'".md5($_P
OST['password']
)."',
'".$_POST[
'email']."
')";
$insert2 =
mysql_query($in
sert);
if(!$insert2)
die(mysql_error
());
echo('Registrat
ion Successful,
Welcome new
member! You can
now login to
your new
account.');
} else {
header("L
ocation:
login.php"<
img
src=http://www.
allsyntax.com/f
orums/images/sm
ilies/wink.gif
border=0>;
} //end not
logged in
} //end submit
not pressed
?>
Login.php
Code:
<?php
include('header
.php');
if($_SESSION['l
ogged_in'] ==
1)
{
//REDIRECT
TO HOMEPAGE
header('Locatio
n: index.php');
} else {
?>
<head><
;link
rel="short
cut icon"
href="favi
con.ico"
>
<link
rel="icon&
quot;
href="anim
ated_favicon1.g
if"
type="imag
e/gif"
></head&g
t;
<table
border="0&
quot;
cellpadding=&qu
ot;0"
cellspacing=&qu
ot;0"
style="bor
der-collapse:
collapse"
bordercolor=&qu
ot;#111111"
;
width="100
%"
id="Head&q
uot;>
<tr>
<td
width="62%
">
<table
border="0&
quot;
cellpadding=&qu
ot;0"
cellspacing=&qu
ot;0"
style="bor
der-collapse:
collapse"
bordercolor=&qu
ot;#111111"
;
width="100
%"
id="AutoNu
mber7">
<tr>
<td
width="60%
">
<a
href="inde
x.php">
<img
border="0&
quot;
src="image
s/logo.png"
;
width="506
"
height="10
4"><
/a></td&g
t;
<td
width="40%
">Hello
, <?php
echo($user);
echo($message);
?></td>
;
</tr>
</table>
<table
border="0&
quot;
cellpadding=&qu
ot;0"
cellspacing=&qu
ot;0"
style="bor
der-collapse:
collapse"
bordercolor=&qu
ot;#111111"
;
width="100
%"
id="Menu&q
uot;
height="34
"
background=&quo
t;images/backme
nu.png">
;
<tr>
<td
width="100
%"
height="34
">
<p
align="cen
ter">
<a
href="inde
x.php">
<img
border="0&
quot;
src="image
s/homebtn.png&q
uot;
width="125
"
height="50
"></
a><a
href="mp3.
php">&l
t;img
border="0&
quot;
src="image
s/mp3btn.png&qu
ot;
width="125
"
height="50
"></
a></td>
;
</tr>
</table>
<p></p
>
<table
border="0&
quot;
cellpadding=&qu
ot;0"
cellspacing=&qu
ot;0"
style="bor
der-collapse:
collapse"
bordercolor=&qu
ot;#111111"
;
width="100
%"
id="Head&q
uot;>
<tr>
<td
width="62%
">
<table
border="0&
quot;
cellpadding=&qu
ot;0"
cellspacing=&qu
ot;0"
style="bor
der-collapse:
collapse"
bordercolor=&qu
ot;#111111"
;
width="100
%"
id="AutoNu
mber9"
height="24
">
<tr>
<td
width="50%
"
height="24
">
<p
align="cen
ter">Do
n't have an
account?
Register Now!
</td>
<td
width="50%
"
height="24
">
<p
align="cen
ter">Al
ready a member?
Login
here</td>
</tr>
</table>
<table
border="0&
quot;
cellpadding=&qu
ot;0"
cellspacing=&qu
ot;0"
style="bor
der-collapse:
collapse"
bordercolor=&qu
ot;#111111"
;
width="100
%"
id="AutoNu
mber10">
;
<tr>
<td
width="50%
">
<p>
<table>
<form
name="sign
up"
action="re
gister.php"
;
method="PO
ST">
<tr>
<td>Usern
ame:
</td>
<td>
<input
type="text
" id
="username
"
name="user
name"
value="&qu
ot;
maxlength="
;30"
size="20&q
uot;>
<BR></
td>
</tr>
<tr>
<td>Passw
ord:</td>
<td>
<input
type="pass
word"
id="passwo
rd"
name="pass
word"
value="&qu
ot;
maxlength="
;30"
size="20&q
uot;><BR&
gt; (minimum 6
characters)<
/td>
</tr>
<tr>
<td>Verif
y
Pass:</td>
;
<td>
<input
type="pass
word"
id="verify
_password"
name="veri
fy_password&quo
t;
value="&qu
ot;
maxlength="
;30"
size="20&q
uot;><BR&
gt;
</td>
</tr>
<tr>
<td>Email
:</td>
<td><i
nput
type="text
"
id="email&
quot;
name="emai
l"
value="&qu
ot;
size="30&q
uot;><br&
gt;</td>
</tr>
<tr>
<td>Click
to Complete
Signup:</td&
gt;
<td><i
nput
type="subm
it"
id="submit
"
name="subm
it"
value="sub
mit">&l
t;/td>
</tr>
</form>
</table>
</td>
<td
width="50%
">
<p>&n
bsp;<form
name="logi
n"
method="PO
ST"
action="in
.php">
<table>
<tr>
<td>Usern
ame:<input
type="text
"
id="userna
me"
name="user
name"
size="20&q
uot;></td
>
</tr>
<tr>
<td>Passw
ord:<input
type="pass
word"
id="passwo
rd"
name="pass
word"
size="20&q
uot;></td
>
</tr>
<tr>
<td>
<p
align="cen
ter">&a
mp;nbsp;&nb
sp; &a
mp;nbsp;&nb
sp; &a
mp;nbsp;&nb
sp; &a
mp;nbsp;
<input
type="subm
it"
value="Sub
mit"
name="subm
it"
id="submit
"></
td>
</tr>
<tr>
<td>Remem
ber Me?
<input
type="chec
kbox"
name="stay
_in[]"
checked="y
es"
value="ON&
quot;></t
d>
</tr>
</table>
</form>&l
t;/p>
</form>
</td>
</tr>
</table>
<table
border="0&
quot;
cellpadding=&qu
ot;0"
cellspacing=&qu
ot;0"
style="bor
der-collapse:
collapse"
bordercolor=&qu
ot;#111111"
;
width="100
%"
id="AutoNu
mber11">
;
<tr>
<td
width="100
%"><
br><?php
include('footer
.php');
?></td>
;
</tr>
<?php
}
?>
</table><
/div>
in.php
(function for
login)
Code:
<?php
ob_start();
session_start()
;
require_once('d
b_connect.php')
;
if(isset($_SESS
ION['username']
) &&
isset($_SESSION
['password']))
{
//REDIRECT TO
USERS
PROFILE...
header("Lo
cation:
http://localhos
t/new"  ;
} //end if
logged in
//IF SUBMIT
BUTTON
PRESSED
if(isset($_POST
['submit']))
{
if(!$_POST['use
rname'])
die("Error
: You must
enter your
username before
logging
in."  ;
if(!$_POST['pas
sword'])
die("Error
: You must
enter your
password before
logging
in."  ;
//set cookie
if checked
if(!empty($_POS
T['stay_in']))
{
$joined
=''.$_POST['use
rname'].'[]'.md
5($_POST['passw
ord']).'';
setcookie('logi
n_cookie',
$joined,
2147483647,
'/',
'.localhost');
} //end
if
//verify
user...
$get_user =
mysql_query(&qu
ot;SELECT *
FROM `members`
WHERE username
=
'".$_POST[
'username'].&qu
ot;' AND
user_password =
'".md5($_P
OST['password']
)."'"<
img
src=http://www.
allsyntax.com/f
orums/images/sm
ilies/wink.gif
border=0>;
$q =
mysql_fetch_obj
ect($get_user);
if(!$q)
die("Login
Failure: An
error occured,
please verify
your username
and password
are
correct." ;
//set session
variables
$_SESSION['logg
ed_in'] = 1;
$_SESSION['user
name'] =
$_POST['usernam
e'];
$_SESSION['pass
word'] =
$_POST['passwor
d'];
session_write_c
lose();
header("Lo
cation:
http://localhos
t/new" ;
} else {
header("Lo
cation:
login.php"<
img
src=http://www.
allsyntax.com/f
orums/images/sm
ilies/wink.gif
border=0>;
}//end else
?>
Logout.php
Code:
<?php
session_start()
;
$_SESSION['logg
ed_in'] = 0;
setcookie('logi
n_cookie',
"",
time() - 60,
'/',
'.localhost');
session_destroy
();
header("Lo
cation:
index.php"<
img
src=http://www.
allsyntax.com/f
orums/images/sm
ilies/wink.gif
border=0>;
?>
If you would
like to display
users name to
certain pages,
just include
header.php to
those pages and
echo $user and
anything after
it. You can
change the
message in
header.php.
Thanks to
everyone who
mentioned these
solutions.
Example:
Code:
<?php
include('header
.php');
echo($user);
echo($message);
?>
Don't forget
that my
login.php has a
table for login
and to
register.
Almost like
YouTube's.
NOTE:::
Remember to
change the
paths!
I got all my
answers from
genius users up
in this forum.
Thanks to
everyone who
tried to
resolve my
problem. Edited at 02:51:35 am on 02/25/08
|
Viewed: 37,505 Times | |  |
mwalsh |
Subject: "re: Member
System Sample!"
Posted: @ 4:13 am on Apr 07 2008
|
|
|
Member #: 654 Rank: User - (6) Since: 04/07/08 Posts: 6
|
Sarvar
said...
<
i>
Ok. I finally
got everything
working. Thanks
to bs0d for
writing the
script! This is
for people who
are still
struggling with
it. Here's
what I did:
//array of
invalid
characters
$junk =
array('.' ,
',' , '/' ,
'\'' ,
'`' , ';' ,
'[' , ']' ,
'-', '_',
'*',
'&',
'^', '%',
'$', '#',
'@', '!',
'~', '+',
'(', ')',
'|', '{',
'}',
'<',
'>',
'?', ':',
'"',
'=');
Thanks Sarvar!
Look what I get
when *I* copy
and paste from
the page
http://www.alls
yntax.com/tutor
ials/view.php?i
d=26&entire
=1
(paste
start)
//array of
invalid
characters
$junk =
array('.' ,
',' , '/' ,
'\' , '`'
, ';' , '['
, ']' ,
'-', '_',
'*',
'&',
'^', '%',
'$', '#',
'@', '!',
'~', '+',
'(', ')',
'|', '{',
'}',
'<',
'>',
'?', ':',
'"',
'=');
//starting
lenght of
username
(paste end)
I'm so
grateful to you
because I'm
still vibrating
with
frustration on
the error
message the
*original*code*
provides.
Where did you
get the line
you use? It
doesn't error
like the
author's
does!
My question now
is whether to
delete
everything I
got from the
pro and use
your setup
since at least
you indicate it
works. I mean,
what else did
you change to
make it work?
I really hate
this, I really
hate having to
go line-by-line
to fix
something
someone posted
to help us. I
really hate
asking, but did
he even check
his own
*posted* code
-- that is, get
it back off his
post and see if
it still works?
Please ignore
me, I'm livid
and would have
put this URL in
my DNS server
to dev null,
but I really
need this
script. I'm
way n00 at PHP.
Wish me luck.
Or that I find
a place that
doesn't
require luck!
*grin*
Thanks,
Sarvar,
Michael
mwalsh7782 at
that yahoo
place
|
Viewed: 34,999 Times | |  |
mwalsh |
Subject: "re: Member
System Sample!"
Posted: @ 4:24 am on Apr 07 2008
|
|
|
Member #: 654 Rank: User - (6) Since: 04/07/08 Posts: 6
|
Thanks,
Sarvar,
I'm going to
delete
everything I
bothered to do
based on the
site
"tutorial
" over
the past hours.
The page
http://www.alls
yntax.com/tutor
ials/view.php?i
d=26&entire
=1 is not even
defective.
It's the
worst. It's a
lie that it's
in the least
bit useful,
since no
working code
can be made
from it.
Have you
considered
asking the
admins of this
site to have it
removed? Maybe
you describe
what you did to
make something
work and post
it in it's
place? I'll
try to leave a
message to the
admins, myself,
in a moment.
But this thing,
though it may
be cool, is
totally
un-usable as a
tutorial goes.
What is someone
like me to do?
go around try
to find all
your posts and
the info you
got and then
try, like you
did, to fix the
original post?
This is so
incredibly
ludicrous.
Admins should
*check* what
people post on
their sites and
verify it's
"doable.
"
I've been
around since
1988 all day on
PCs, n00B at
PHP, though.
But I can say
nothing has
ever in all
those years
infuriated me
as much as
this. I am
totally ripshit
that I have to
delete all my
work, having
learned nothing
of PHP, only
learned two
things:
1.) it's a
defective
"tutorial
" and
2.) Sarvar's
post looks like
he fixed it.
Pray for me
that my
adrenaline
wears off.
Jeez, this
sucks. What a
piece of
*^)*^&(.
I'm posting
this at the
risk of this
being viewed as
flame because
it just
damn-well needs
to be said.
Spoiler: I'm
so mad I can't
resist posting
this.
###############
############
Warning:
session_start()
: Cannot send
session cookie
- headers
already sent by
(output started
at
session_start(
);
and later
again.
Now I see that
the author
didn't mean
for it to be
one page with
one
require_once,
he meant to
branch out to
different
files. Sarvar,
could you add
an explaining
tutorial?
There is a
logic and
explanation
which is
missing -- and
also presumably
your code
doesn't error?
So I'm going
to delete all
the original
work I've done
and try yours.
I hope the
author deletes
his tutorial
and actually
checks
everything
he's ever
posted and then
goes to his
(computerless)
room.
|
Viewed: 34,992 Times | |  |
mwalsh |
Subject: "re: Member
System Sample!"
Posted: @ 6:51 am on Apr 07 2008
|
|
|
Member #: 654 Rank: User - (6) Since: 04/07/08 Posts: 6
|
Sarvar, your
post above
errored-out in
header.php
until I added
the the last
right-parenthes
is, as shown in
this line:
$qu =
mysql_query(&q
uot;SELECT
`user_password`
FROM `members`
WHERE
`username` =
'".addsl
ashes($user).&
quot;'"
|
Viewed: 34,989 Times | |  |
mwalsh |
Subject: "re: Member
System Sample!"
Posted: @ 7:28 am on Apr 07 2008
|
|
|
Member #: 654 Rank: User - (6) Since: 04/07/08 Posts: 6
|
Sarvar,
This works for
you?
$message =
"<br&g
t;Please <a
href=login.php&
gt;Login</a&
gt; or
<a
href=login.php&
gt;Register<
/a>
here";
|
Viewed: 34,983 Times | |  |
bs0d |
Subject: "re: Member
System Sample!"
Posted: @ 1:46 pm on Apr 07 2008
|
|
|
 Member #: 1 Rank: Admin. - (1,505) Since: 02/06/05 Posts: 600 From: USA
|
mwalsh,
I am the one
and only site
admin. I wrote
the script, and
it's the same
script used on
this site that
you signed up
and logged in
with. If you
don't like the
way it is
written, don't
read it. But by
the way you
talk, you
didn't even
try to read and
learn from the
article. There
is probably an
error in the
$junk array
syntax in the
sample provided
- I'll check
into that.
I assure you,
the script
works and works
well. The
problem is you
mess it up / do
not implement
correctly. You
are new to PHP,
so this is
expected to
happen. I try
to explain each
part and
variable in
detail.
I do not
welcome users
as yourself to
this site. The
article will
stay intact and
live on the
site. It has
helped many
users get a
start, you're
out-numbered
bro. This is
not a
plug-n-play
script. If it
was, I would
build an
install script
to prevent you
from screwing
it up.
Quit passing
judgment on
topics you have
no experience
of. I do accept
constructive
criticism, but
you have made
too many
ambiguous
statements that
amount to
nothing.
One more thing,
I have coded a
script to ban
members, and it
works.
Edited at 01:57:59 pm on 04/07/08
|
Viewed: 34,963 Times | |  |
mwalsh |
Subject: "re: Member
System Sample!"
Posted: @ 10:52 pm on Apr 09 2008
|
|
|
Member #: 654 Rank: User - (6) Since: 04/07/08 Posts: 6
|
My apologies.
I will get back
and respond
Constructively,
if this comment
works and you
aren't Using
the ban-user
script!
*smile*
Yeah, this
could be
constructive,
so I will come
back to it. I
DID have a
point, but
yeah, I was
Very
aggravated.
More than, I
thought about
it when I
mentioned this
to a friend,
for maybe ten
years as I can
remember. No
excuse, but
that is the way
it was for me.
The script,
from Savra,
works
wonderfully --
it takes only
the kind of
working-up that
you describe.
But instead of
complaining, I
will try to
share
constructively
about a user
view.
|
Viewed: 34,920 Times | |  |
Genius |
Subject: "re: Member
System Sample!"
Posted: @ 7:20 pm on Apr 10 2008
|
|
|
 Member #: 582 Rank: User - (77) Since: 02/18/08 Posts: 76 From: kmmk
|
Ok, sorry for
late post, this
is ***NOT MY
SCRIPT***,
This SCRIPT
BELONGS TO
""b
s0d"&quo
t;
All I did was
search these
forums to
problems I
faced during
implementing
the script,
once it worked,
I edited the
"lines&q
uot; which had
errors. Then,
post the fixes
as sample
here.
You should not
thank me, Thank
to bs0d for his
work.
Regards,
Sarvar
|
Viewed: 34,896 Times | |  |
solphate |
Subject: "re: Member
System Sample!"
Posted: @ 2:57 am on May 06 2008
|
|
|
Member #: 581 Rank: User - (24) Since: 02/18/08 Posts: 24
|
|
Viewed: 34,399 Times | |  |
David1159 |
Subject: "re: Member
System Sample!"
Posted: @ 5:58 pm on May 06 2008
|
|
|
 Member #: 526 Rank: User - (81) Since: 12/27/07 Posts: 81 From: usa
|
There is
nothing wrong
with bs0d, it
is very easy to
integrate with
any current
php/mysql
system as long
as you read the
tut.
Coding is
simply CST...
Combining $hit
Together. We
make different
$hit to run in
unison
correctly. |
Viewed: 34,371 Times | |  |
idejuan |
Subject: "re: Member
System Sample!"
Posted: @ 5:00 pm on Jun 13 2008
|
|
|
Member #: 705 Rank: User - (1) Since: 06/13/08 Posts: 1
|
Hello,
The login page
works for me.
But I cannot
get the session
variables in
the new page.
i.e. the
following
variable is 0
all the time,
even if the the
user data for
login is
correct.
$_SESSION['log
ged_in'] =
0
I copied all
the scripts in
the tutorial,
so don't have
a clue what is
going wrong
thanks for
helping
ignacio
|
Viewed: 33,602 Times | |  |
David1159 |
Subject: "re: Member
System Sample!"
Posted: @ 8:28 pm on Jun 13 2008
|
|
|
 Member #: 526 Rank: User - (81) Since: 12/27/07 Posts: 81 From: usa
|
On the top of
your pages
where the
<?php
starts...
add this:
session_start()
;
I think a lot
of you guys are
missing this in
the tutorial.
In the tutorial
bS0d says
create a
page_header.php
file, which
would be
included on
every page by
using
include("
page_header.php
" ;
Anytime you
want to use
session
variables you
have to turn it
on for that one
webpage.
session_start()
; in a basic
sense it is a
ON switch, the
OFF switch is
session_write_c
lose();
That should do
it for you.
Cheers
Coding is
simply CST...
Combining $hit
Together. We
make different
$hit to run in
unison
correctly. |
Viewed: 33,583 Times | |  |
bob C |
Subject: "re: Member
System Sample!"
Posted: @ 2:37 pm on Nov 11 2008
|
|
|
Member #: 770 Rank: User - (2) Since: 10/18/08 Posts: 1 From: belgium
|
Im kind of lost
here. Could
somebody be so
kind to explain
witch paths I
need to change
in
register.php?
|
| Viewed: 32,095 Times | |  |
Genius |
Subject: "re: Member
System Sample!"
Posted: @ 2:11 am on Nov 12 2008
|
|
|
 Member #: 582 Rank: User - (77) Since: 02/18/08 Posts: 76 From: kmmk
|
Code:
Code:
<?php
session_start()
;
require_once('
db_connect.php
');
//SEE IF
ALREADY LOGGED
IN
if($_SESSION['
logged_in'] ==
1)
{
//REDIRECT TO
HOMEPAGE
header('Locati
on: http://' .
$_SERVER['HTTP
_HOST'] .
'');
} else {
if(isset($_POST
['submit']))<
br />
{
//BEGIN
CHECKING
USERNAME...
if(!$_POST['us
ername'])
die('Alert:
username field
was
blank.');
//array of
invalid
characters
$junk =
array('.' ,
',' , '/' ,
'\'' ,
'`' , ';' ,
'[' , ']' ,
'-', '_',
'*',
'&',
'^', '%',
'$', '#',
'@', '!',
'~', '+',
'(', ')',
'|', '{',
'}',
'<',
'>',
'?', ':',
'"',
'=');
//starting
lenght of
username
$len =
strlen($_POST[
'username']);<
br />
//replace
invalid
characters
$_POST['userna
me'] =
str_replace($ju
nk, '',
$_POST['userna
me']);
$test =
$_POST['userna
me'];
//if lenghts
are different
($len smaller),
invalid
characters
found, so
prompt
error.
if(strlen($test
) != $len) {
die('Username
Error: Username
contained
invalid
characters. You
can only use
A-Z, 0-9 and
the
underscore
(_).');
}
//Check if
username
already
exists...
$q2 =
mysql_query(&q
uot;SELECT *
FROM `members`
WHERE
`username` =
'".$_POS
T['username']
."'&quo
t;;
$q3 =
mysql_fetch_obj
ect($q2);
if($q3->user
name ==
$_POST['userna
me']) {
die('<BR>
;<BR>Sorr
y, but the
username
"'.$q3-&
gt;username.'
" is
taken, please
choose
another.');
}
//PASSWORD
if(!$_POST['pa
ssword']) {
die('Error:
Password field
was
blank');
}
if(!$_POST['ve
rify_password'
]) {
die('Error:
Verify Password
field was
blank.');
}
if($_POST['pas
sword'] !=
$_POST['verify
_password'])
{
die('Error:
The passwords
do not
match.');
}
if(strlen($_POS
T['password']
) < 6 ) {
die('Error:
Your password
is too short.
Must be 6 or
more characters
in
length.');
}
//ADD NEW
MEMBER
$insert
="INSERT
INTO `members`
(username,
user_password,
user_email)
VALUES
('".$_PO
ST['username'
]."',
'".md5($
_POST['passwor
d'])."'
,
'".$_POS
T['email'].&
quot;')"
;
$insert2 =
mysql_query($in
sert);
if(!$insert2)
die(mysql_error
());
echo('Registra
tion
Successful,
Welcome new
member! You can
now login to
your new
account.');
} else {
header("L
ocation:
login.php"
;;
} //end not
logged in
} //end submit
not pressed
?>
Change line:
Code:
require_once(
'db_connect.php
')
to file where
connection to
mysql
occurs.
That's it. I
think.
|
Viewed: 32,079 Times | |  |
harrypotter101 |
Subject: "re: Member
System Sample!"
Posted: @ 1:04 am on Nov 24 2008
|
|
|
Member #: 792 Rank: User - (3) Since: 11/24/08 Posts: 3
|
ok i got all
the files
uploaded to my
websites root
now where do i
put em from
there?? sorry
noob at all of
this plz
respond fast
anyone?
|
Viewed: 31,886 Times | |  |
David1159 |
Subject: "re: Member
System Sample!"
Posted: @ 7:32 pm on Dec 01 2008
|
|
|
 Member #: 526 Rank: User - (81) Since: 12/27/07 Posts: 81 From: usa
|
harrypotter101
said...
<
i>
ok i got all
the files
uploaded to my
websites root
now where do i
put em from
there?? sorry
noob at all of
this plz
respond fast
anyone?
It is not good
to copy and
paste this
stuff, it will
have errors and
you'll not
understand what
goes where or
how to build on
top of it.
I am not sure
what you mean,
if you uploaded
the files to
your site
already, where
else can you
put them? That
is where they
go.
Coding is
simply CST...
Combining $hit
Together. We
make different
$hit to run in
unison
correctly. |
Viewed: 31,744 Times | |  |
harrypotter101 |
Subject: "re: Member
System Sample!"
Posted: @ 11:37 pm on Dec 06 2008
|
|
|
Member #: 792 Rank: User - (3) Since: 11/24/08 Posts: 3
|
like idk which
one has the
code to put the
login system on
all my pges
|
Viewed: 31,675 Times | |  |
Olschan |
Subject: "re: Member
System Sample!"
Posted: @ 6:56 pm on Dec 20 2008
|
|
|
Member #: 800 Rank: User - (2) Since: 12/20/08 Posts: 2
|
|
Viewed: 31,426 Times | |  |
Olschan |
Subject: "re: Member
System Sample!"
Posted: @ 8:12 pm on Dec 21 2008
|
|
|
Member #: 800 Rank: User - (2) Since: 12/20/08 Posts: 2
|
ok my login
works now i
need to fix
session
|
Viewed: 31,368 Times | |  |
Gailen |
Subject: "re: Member
System Sample!"
Posted: @ 3:37 am on Jan 04 2009
|
|
|
Member #: 813 Rank: User - (1) Since: 01/04/09 Posts: 1
|
Please explain
ob_start() and
session_start()
and when they
should be used.
It seems like
they are being
used after each
new
"<?php
" line.
Is this
correct?
|
Viewed: 31,090 Times | |  |
bs0d |
Subject: "re: Member
System Sample!"
Posted: @ 11:37 pm on Jan 04 2009
|
|
|
 Member #: 1 Rank: Admin. - (1,505) Since: 02/06/05 Posts: 600 From: USA
|
Gailen
said...
<
i>
Please explain
ob_start() and
session_start()
and when they
should be used.
It seems like
they are being
used after each
new
"<?php
" line.
Is this
correct?
ob_start()
"This
function will
turn output
buffering on.
While output
buffering is
active no
output is sent
from the script
(other than
headers),
instead the
output is
stored in an
internal
buffer."
session_start(
)
"creates
a session or
resumes the
current one
based on the
current session
id that's
being passed
via a request,
such as GET,
POST, or a
cookie."
Edited at 11:41:59 pm on 01/04/09
|
Viewed: 31,065 Times | |  |
Viewing Page: 1 of 2 |
|