View Full Version : Auto Signup
Lost ?
02-12-2005, 10:27 PM
Hey guys wazup.
Im making my first flash website with an auto signup page but if you know me I Suck at pHp.
I just want a signup page that automatically adds a username and password to a DataBase of some sort and allows them to Login any time.
Oh yeah and a way for the Login page to remember all the passwords and usernames.
Im sure you pHp experts know what I mean!!
( \/ )
(O.O)
(> <)
/_|_\
Thanks!
Dark_Element
02-14-2005, 08:45 AM
Hi my pie loving friend. lol
I dont really get what you mean by that. why would you want a automatically created username and password for your client? isnt it better for them to just chose one themselves?
a little more explanation of what is supposed to happen would be good.
Lost ?
02-14-2005, 08:57 AM
Thanks Heaps For Replying, I thought noone would answer.
Sorry if I explained it wrong. I want the user to choose their username and password but I want the code to make the computer memorize it and allow the user to login any time. Just your standard Signup and Login system.
brendanww
02-14-2005, 01:30 PM
if you suck at php, you might want to try doing the whole site entirely in php first, and then turn it into flash.
Lost ?
02-15-2005, 02:34 AM
No I dont entirely suck at it i just need help with this c0d3. It cant be to hard almost every site has a login system
Dark_Element
02-15-2005, 10:20 AM
ok this is very easy.
try this:
run this code first and copy down what it returns in your browser:
<?php
echo(md5('a password to keep morons from injecting into your stuff'));
?>
remember the original and the generated keys
MySQL table creating query:
CREATE TABLE logins (
id int(9) unsigned not null auto_increment,
username varchar(255),
password varchar(255),
primary key(id)
);
Signup:
<?php
if (empty($_POST['key']) || md5($_POST['key']) != 'the generated key') exit('Stop hacking');
$connect = mysql_connect('host', 'user', 'pass');
mysql_select_db('database') or die('error=selectdb');
mysql_query('INSERT INTO logins VALUES("", "'.$_POST['user'].'", "'.(md5($_POST['pass'])).'")') or die('error=insert');
echo('success=true');
mysql_close($connect);
?>
Login:
<?php
if (empty($_POST['key']) || md5($_POST['key']) != 'the generated key') exit('Stop hacking');
$connect = mysql_connect('host', 'user', 'pass');
mysql_select_db('database') or die('error=selectdb');
$q = mysql_query('SELECT id FROM logins WHERE username = "'.$_POST['user'].'" AND password = "'.(md5($_POST['pass'])).'" LIMIT 1');
if (mysql_num_rows($q) < 1) exit('error=badinfo');
echo('success=true');
?>
Actionscript side - signup:
_root.phpCom = new LoadVars();
_root.phpCom.user = whatevertextfield.text;
_root.phpCom.pass = whatevertextfield.text;
_root.phpCom.key = "the non generated key"
_root.phpCom.onData = function (success) {
if (success) {
if (_root.phpCom.error != undefined) {
// error handeling
} else {
// success handeling
}
} else {
//error handeling
}
}
the login code would be the same. except you are trying to detect if _root.phpCom.success does equals to undefined
PS: those codes were not tested and may contain minor syntax errors
hum... i think i need to stop posting full codes lol. i may have to start charging people LMAO...
Lost ?
02-16-2005, 06:03 AM
Thanks heaps Dark Element!!! :D :D :D :D
Dark_Element
02-16-2005, 06:40 AM
oh yea... i forgot something... you should use mysql_escape_string() for the user vars. cos people MAY try to use query injections on you if they hate you enough
Lost ?
02-16-2005, 07:09 AM
Ok cool, Thanks again :D :D
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.