phake Posted May 15, 2007 Share Posted May 15, 2007 Alright, I know HTML, CSS, and I'm a PHP beginner. I've tried creating a member database using ifastnet.com, but it seems to never work. When I say "member database", I mean just a basic member sigh up. Would anyone be willing to help me? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/ Share on other sites More sharing options...
phast1 Posted May 15, 2007 Share Posted May 15, 2007 Are you getting some sort of error message? The only way anyone can help is if you give some detail about the problem Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-253965 Share on other sites More sharing options...
phake Posted May 15, 2007 Author Share Posted May 15, 2007 It says: Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/damianlayouts/connect.php on line 21 Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-253973 Share on other sites More sharing options...
phake Posted May 15, 2007 Author Share Posted May 15, 2007 Here are my codes: I used this code for connect.php: <?php // This script will connect the user to your mySQL database. // It will also check it they're logged in or not. // It should be included on every page you create. // Set the variables below to match your settings $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $dbname = 'mygame'; $link = mysql_pconnect($dbhost, $dbuser, $dbpass) or die("Could not connect to server."); $selectdb = mysql_select_db($dbname, $link) or die("Could not connect to database."); // Check to see if user is logged in session_start(); if((!isset($_SESSION['id'])) || (!isset($_SESSION['username'])) || (!isset($_SESSION['password']))) { unset($_SESSION['username']); unset($_SESSION['password']); unset($_SESSION['id']); $loggedin = 0; } else { $loggedin = 1; } ?> This code for index.php: <?php include('connect.php'); if($loggedin == '0') { if(isset($_POST['submit'])) { // Make sure all forms were filled out. if((!isset($_POST['username'])) || (!isset($_POST['pass'])) || ($_POST['username'] == '') || ($_POST['pass'] == '')) die("Please fill out the form completely. <br><br> <a href=index.php>Continue</a>"); // Get user's record from database $player = @mysql_query("SELECT id, username, password, registered, lastlogin FROM players WHERE username = '".$_POST['username']."'"); $player = @mysql_fetch_assoc($player); if($player['id'] == false) die("Sorry, that user is not in our database.<br><br> <a href=index.php>Back</a>"); else if($player['password'] != md5($_POST['pass'])) die("Wrong password!<br><br> <a href=index.php>Back</a>"); // set session variables $_SESSION['id'] = $player['id']; $_SESSION['username'] = $player['username']; $_SESSION['password'] = $player['password']; // update last login $date = date("m/d/y"); $update = @mysql_query("UPDATE players SET lastlogin = '$date' WHERE id = '".$_SESSION['id']."'"); echo 'You are now logged in!'; } else { echo 'You are not logged in. <br><br> <form action=index.php method=post> Username: <input type=text name=username><br> Password: <input type=password name=pass><br> <input type=submit name=submit value=Submit> </form> Would you like to <a href=register.php>register?</a>'; } } else { echo 'You are logged in! Welcome to my game, '.$_SESSION['username'].'! <br><br> <a href=logout.php>Click Here to Logout</a>'; } ?> This code for register.php: <?php include('connect.php'); if($loggedin == '1') die("You can't register another account while you're logged in."); // Register Script // So, the register script is a sample of the basic elements of // coding used in a simple sim game, namely, putting new data // into databases. if(isset($_POST['submit'])) { // trim removes the whitespaces from the beginning and end of text // this keeps someone from having a username of " " $uname = trim($_POST['username']); // Make sure all forms were filled out. if((!isset($_POST['username'])) || (!isset($_POST['pass'])) || ($uname == '') || ($_POST['pass'] == '')) die("Please fill out the form completely. <br><br> <a href=register.php>Continue</a>"); // Make sure name hasn't already been used. $check = @mysql_query("SELECT id FROM players WHERE username = '$uname'"); $check = @mysql_num_rows($check); if($check > 0) die("Sorry, that username has already been taken. Please try again. <br><br> <a href=register.php>Continue</a>"); // Encrypt password $pass = md5($_POST['pass']); $date = date("m/d/y"); // Finally, create the record. $newPlayer = @mysql_query("INSERT INTO players (username, password, registered) VALUES ('$uname', '$pass', '$date')") or die("Error: ".mysql_error()); echo 'You have been registered! You may now <a href=index.php>Log in</a>.'; } else { // A simple example of a form. echo '<form action=register.php method=post> Username: <input type=text name=username><br> Password: <input type=password name=pass><br> <input type=submit name=submit value=Submit> </form>'; } ?> This code for logout.php <?php include('connect.php'); unset($_SESSION['id']); unset($_SESSION['username']); unset($_SESSION['password']); $_SESSION = array(); @session_destroy(); echo 'You have been logged out. <a href=index.php>Continue</a>'; ?> And this for the database: username varchar 150 password varchar 150 registered varchar 15 lastlogin varchar 15 Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-253978 Share on other sites More sharing options...
trq Posted May 15, 2007 Share Posted May 15, 2007 Have you created the database mygame? Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-253979 Share on other sites More sharing options...
phake Posted May 15, 2007 Author Share Posted May 15, 2007 Yes, I did, and used this for it: username varchar 150 password varchar 150 registered varchar 15 lastlogin varchar 15 Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-253980 Share on other sites More sharing options...
npsari Posted May 15, 2007 Share Posted May 15, 2007 I wouldnt use include (connect.php) Perhpas it is better if you connected each time And try not to use $ for name and passwords Just put them directly in the code $con = mysql_connect("localhost","name","password"); That would propably get rid of some hustle Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-253982 Share on other sites More sharing options...
phake Posted May 15, 2007 Author Share Posted May 15, 2007 Okay, but wait, I don't believe my database has a password. So... // Set the variables below to match your settings $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $dbname = 'mygame'; And if I took away connect.php, then I'd have to edit the pages that include connect.php, but then how does the script know how to connect? (I'm sorry for all this, I'm such a PHP n00b, haha) Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-253985 Share on other sites More sharing options...
phast1 Posted May 15, 2007 Share Posted May 15, 2007 It looks like you need to set your database settings in the connect.php file: $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $dbname = 'mygame'; You will need to obtain these settings from ifastnet.com.. The 'localhost' and 'mygame' settings are probably fine, but you definitely won't be able to connect as 'root', especially not without a password Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-253988 Share on other sites More sharing options...
ryeman98 Posted May 15, 2007 Share Posted May 15, 2007 It looks like you need to set your database settings in the connect.php file: $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $dbname = 'mygame'; You will need to obtain these settings from ifastnet.com.. The 'localhost' and 'mygame' settings are probably fine, but you definitely won't be able to connect as 'root', especially not without a password Sometimes localhost won't even work. On my site I have to use sql3.mysql or something similar to that. Make sure you find the correct connecting information. Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-253989 Share on other sites More sharing options...
npsari Posted May 15, 2007 Share Posted May 15, 2007 thats weired to me, cus i alwasy dealt with database that needs password Well, the error says you need password So, there must be something you need to put Or perhaps, just leave it empty and get rid of $ i think, and put details straight away or use print"$dbuser" to see a little on whats going on you know, keep trying Cus sometimes, i know the connection to databse can get really tricky (and it is simple) Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-253991 Share on other sites More sharing options...
phake Posted May 15, 2007 Author Share Posted May 15, 2007 Yeah..I cannot find any password for the database. Is there a way to create one? Bad ifastnet (moves finger) Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-253993 Share on other sites More sharing options...
phake Posted May 15, 2007 Author Share Posted May 15, 2007 Well, I found my server, put that in, and now it shows: Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'sq12.ifastnet.co'@'localhost' (using password: NO) in /home/damianlayouts/connect.php on line 21 Should I switch hosts? If I did, the other'd have to be free, as I have no serious plans as of yet, I mean, I'm just a beginner. Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-253996 Share on other sites More sharing options...
ryeman98 Posted May 15, 2007 Share Posted May 15, 2007 What is your connect info now? Don't post the password though, just put stars(***) Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-254000 Share on other sites More sharing options...
phake Posted May 15, 2007 Author Share Posted May 15, 2007 I don't know the pass, but here's the code in connect.php: <?php // This script will connect the user to your mySQL database. // It will also check it they're logged in or not. // It should be included on every page you create. // Set the variables below to match your settings $dbhost = 'localhost'; $dbuser = 'sq12.ifastnet.com'; $dbpass = ''; $dbname = 'mygame'; $link = mysql_pconnect($dbhost, $dbuser, $dbpass) or die("Could not connect to server."); $selectdb = mysql_select_db($dbname, $link) or die("Could not connect to database."); // Check to see if user is logged in session_start(); if((!isset($_SESSION['id'])) || (!isset($_SESSION['username'])) || (!isset($_SESSION['password']))) { unset($_SESSION['username']); unset($_SESSION['password']); unset($_SESSION['id']); $loggedin = 0; } else { $loggedin = 1; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-254003 Share on other sites More sharing options...
npsari Posted May 15, 2007 Share Posted May 15, 2007 I think i know what is the problem Do you use C panel? just to make sure Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-254005 Share on other sites More sharing options...
corbin Posted May 15, 2007 Share Posted May 15, 2007 Ummm the code is correct (I'm assuming). The problem is that it cannot connect to the mysql server do to the mysql server rejecting the username and/or password..... Find out that stuff from your host and build the DB and you should be good to go. Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-254006 Share on other sites More sharing options...
ryeman98 Posted May 15, 2007 Share Posted May 15, 2007 I think you need to... Replace: localhost with: sq12.ifastnet.com Now go find your username and password. Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-254008 Share on other sites More sharing options...
npsari Posted May 15, 2007 Share Posted May 15, 2007 When you create a databse You create username and password And assign them to the databse Have u done that if it is recuired Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-254013 Share on other sites More sharing options...
boo_lolly Posted May 15, 2007 Share Posted May 15, 2007 your username may be your login username for ifastnet.com. and 'sq12.ifastnet.com' may be your host. Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-254036 Share on other sites More sharing options...
phast1 Posted May 16, 2007 Share Posted May 16, 2007 Well, you definitely need to figure out your mySQL username and password, otherwise you will never connect successfully.. You should search the ifastnet.com support documents for help or try to contact them if possible.. Be sure to check your signup e-mail that they should have sent you, it might have the info in there.. But, it looks like you put your host name in the user variable, you should probably be setting it like this: $dbhost = 'sq12.ifastnet.com'; $dbuser = 'USERNAME'; $dbpass = 'PASSWORD'; $dbname = 'mygame'; Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-254142 Share on other sites More sharing options...
phake Posted May 16, 2007 Author Share Posted May 16, 2007 My mom took away the laptop and I got it, but no power cord and there's like no battery left! If I find it, I'll tell you guys! Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-254889 Share on other sites More sharing options...
phake Posted May 16, 2007 Author Share Posted May 16, 2007 Now it's saying it can't connect and the problem is at: unset($_SESSION['id']); UGH! Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-254893 Share on other sites More sharing options...
boo_lolly Posted May 17, 2007 Share Posted May 17, 2007 Now it's saying it can't connect and the problem is at: unset($_SESSION['id']); UGH! that's not where the problem is. it may tell you that's where it is, but you have to do a little more searching. it's probably very close. you should post that line, and 5 lines before it, and 5 lines after it. Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-254996 Share on other sites More sharing options...
phake Posted May 17, 2007 Author Share Posted May 17, 2007 I don't know, I don't have experience, and this is all kinda pointless. *sigh* This kinda stuff is so complicated. Quote Link to comment https://forums.phpfreaks.com/topic/51569-creating-a-member-database-using-ifastnetcom/#findComment-254998 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.