Jump to content

Recommended Posts

So...I tryed a different code for register and it still gets a error....help please!

<?phpmysql_connect("MYSQL hostname", "username", "pass") or die(mysql_error()); mysql_select_db("database name") or die(mysql_error()); //Checks if there is a login cookieif(isset($_COOKIE['user']))//if there is, it logs you in and directes you to the members page{ $username = $_COOKIE['user']; $pass = $_COOKIE['Key_my_site'];$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());while($info = mysql_fetch_array( $check )) {if ($pass != $info['password']) {}else{header("Location: members.php");}}}//if the login form is submittedif (isset($_POST['submit'])) { // if form has been submitted// makes sure they filled it inif(!$_POST['username'] | !$_POST['pass']) {die('You did not fill in a required field.');}// checks it against the databaseif (!get_magic_quotes_gpc()) {$_POST['email'] = addslashes($_POST['email']);}$check = mysql_query("SELECT * FROM Users WHERE username = '".$_POST['username']."'")or die(mysql_error());//Gives error if user dosen't exist$check2 = mysql_num_rows($check);if ($check2 == 0) {die('That user does not exist in our database. <a href=register.php>Click Here to Register</a>');}while($info = mysql_fetch_array( $check )) {$_POST['pass'] = stripslashes($_POST['pass']);$info['password'] = stripslashes($info['password']);$_POST['pass'] = $_POST['pass'];//gives error if the password is wrongif ($_POST['pass'] != $info['password']) {die('Incorrect password, please try again.');}else { // if login is ok then we add a cookie $_POST['username'] = stripslashes($_POST['username']); $hour = time() + 3600; setcookie(user, $_POST['username'], $hour); setcookie(Key_my_site, $_POST['pass'], $hour);	//then redirect them to the members area header("Location: members.php"); } } } else {	// if they are not logged in ?> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> Username:   <input type="text" name="username" maxlength="20"><br>Password:   <input type="password" name="pass" maxlength="25"> <br><input type="submit" name="submit" value="Login"> </form> <?php

I'm currently getting a blank screen for itJust in case it's the link code I post it to

<a href="login.php">Login</a>

Edited by e4games
Link to post
Share on other sites

That means that you don't have a table called `users` in the database `ethwam4_Members`.

Link to post
Share on other sites

But I do have a table called "users"........I just checked the login and for some reason when you press the "login" button, the URL doesn't do anything, but I did it the same way that I did it with the register, and that works...

Edited by e4games
Link to post
Share on other sites

I guarantee that the database you are using, ethwam4_Members, does not contain a table called "users". If it did exist, why do you think it would be saying "Table 'ethwam4_Members.users' doesn't exist"? Do you think it's more likely that the database doesn't know what tables it contains, or that you don't know what tables it contains? Have you even bothered to check the database structure? Why do you think the error message is wrong?

Link to post
Share on other sites

I've looked threw the database and there was only 1 table called users, anyways I changed a few other things and it seems to work (didn't even touch the database)Anyways I still don't know what to do with the login issue, I'm gonna post it in the first post becuase I don't think its the way I'm coding the link to get to it, I think it might be the code for the login.... (cause I've have problems with this happening and it was the login code not the hyperlink code)

Link to post
Share on other sites
I've looked threw the database and there was only 1 table called users, anyways I changed a few other things and it seems to work (didn't even touch the database)Anyways I still don't know what to do with the login issue, I'm gonna post it in the first post becuase I don't think its the way I'm coding the link to get to it, I think it might be the code for the login.... (cause I've have problems with this happening and it was the login code not the hyperlink code)
I have only 1 questionUsers Or users your table?I see :)$pass = $_COOKIE['Key_my_site'];$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());while($info = mysql_fetch_array( $check )) if (!get_magic_quotes_gpc()) {$_POST['email'] = addslashes($_POST['email']);}$check = mysql_query("SELECT * FROM Users WHERE username = '".$_POST['username']."'")or die(mysql_error());//Gives error if user dosen't exist$check2 = mysql_num_rows($check); Edited by phpnoob
Link to post
Share on other sites

Your original code is missing at least one closing bracket, it's hard to tell beyond that because the code isn't formatted. If you're seeing a blank page then you don't have error messages enabled on the server, they are probably going to an error log that you can find through FTP.

Link to post
Share on other sites

You can't change error settings on this page, this page has syntax errors so it would never execute the error settings in the first place. You either need to change the settings in php.ini, or look for the error log on the server. You can also create a phpinfo page to see what all of the settings are, that will tell you which error log it's using.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...