0

ya i have this site i am working on and at first it was working fine, im not sure what i did but now it says i registered but when i login i get the error saying invalid username.


So i went and looked at PhpMyAdmin and it did not add the username and password and so on. Like it did not insert everything...

Here is my register.php file ask me if you need anything else.

<html>

<head profile="http://gmpg.org/xfn/11">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

	<title>Version 2 Gaming</title>

	<meta name="generator" content="WordPress 2.3.1" /> <!-- leave this for stats please -->

	<style type="text/css" media="screen">
		@import url( http://wpmix.com/wpdemos/wp-content/themes/blue_rings/style.css );
	</style>

	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://wpmix.com/wpdemos/?feed=rss2" />
	<link rel="alternate" type="text/xml" title="RSS .92" href="http://wpmix.com/wpdemos/?feed=rss" />
	<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="http://wpmix.com/wpdemos/?feed=atom" />

	<link rel="pingback" href="http://wpmix.com/wpdemos/xmlrpc.php" />
		<link rel='archives' title='August 2007' href='http://wpmix.com/wpdemos/?m=200708' />
	<link rel='archives' title='July 2007' href='http://wpmix.com/wpdemos/?m=200707' />
			<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://wpmix.com/wpdemos/xmlrpc.php?rsd" />
 <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://wpmix.com/wpdemos/wp-includes/wlwmanifest.xml" /> </head>

<body><div id="bodybottom"><div id="bodytop">
<div id="page">
	<div id="header">
		<h1><a href="http://wpmix.com/wpdemos/">Version 2 Gaming</a></h1>
		<h2>Pro's in everything you like to know</h2>
		<ul>
			<li class='current_page_item'><a href="http://www.google.com/">Home</a></li>
			<li class="page_item page-item-2"><a href="http://www.google.com" title="About">About</a></li>

<li class="page_item page-item-3"><a href="http://www.google.com/" title="Contact">Contact</a></li>
		</ul>
	</div>
	<div id="container">
		<div id="content">

<div class="post" id="post-5">
	<h2>Become a member!</h2>

	<div class="entry"> <!--Edit this for the main body on the home page-->
		<p>
<?php
echo "<h1>Register</h1>";

$submit = $_POST['submit'];
$username = strtolower(strip_tags($_POST['username']));
$password = strip_tags($_POST['password']);
$repassword = strip_tags($_POST['repassword']);

if ($submit)
{

 //open database
 $connect = mysql_connect("mysql5.000webhost.com","a6027290_members","m26682668");
 mysql_select_db("a6027290_members"); //select database
 
 $namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
 $count = mysql_num_rows($namecheck);

 if ($count!=0)
 {
  echo "Username already taken! <a href='register.php'>Retry</a>";
  die ();
 }

 //check for existance
if ($username&&$password&repassword)
{
	
	if ($password==$repassword)
	{
	
	 //check char length of username
	 if (strlen($username)>25)
	 {
	  echo "You username must be under 25 characters in length";
	 }
	 else
	 {
	  
	  //check password length
	  if (strlen ($password)>25||strlen($password)<6)
	  {
	   echo "Password must be between 6 and 25 characters";
	  }
	  else
	  {
	   //register the user 
	   
	   	//encrypt password
		$password = md5 ($password);
		$repassword = md5($repassword);
	   
	   
	   $queryreg = mysql_query("
	   
	   INSERT INTO users VALUES ('','$username','$password')
	   
	   ");
	   
	   die ("You have been registered! <a href='index.html'>Login</a>");
	   
	  }
	 
	 }
	
	}
	else
		echo "Your passwords do not match";
	
}
else
	echo "Please fill in <b>all</b> fields!";
 
}
?>
<html>
<p>
<form action='register.php' method='POST'>
	<table>
		<tr>
			<td>
			Username:
			</td>
			<td>
			<input type='text' name='username' value='<?php echo $username ?>'>
			</td>
		</tr>
		<tr>
			<td>
			Password:
			</td>
			<td>
			<input type='password' name='password'>
			</td>
		</tr>
		<tr>
			<td>
			re Password:
			</td>
			<td>
			<input type='password' name='repassword'>
			</td>
		</tr>
	</table>
	<p>
	<input type='submit' name='submit' value='Register'>
</form>

</html>

		</p>

			</div>

	<div class="comments">
		<a href="gameguysz@yahoo.com" title="Email me for more info">Email</a>	</div>

</div>

    		</div>
		<div id="sidebar">
			<ul>
	</li>
		<li id="linkcat-2" class="linkcat"><h3>V2 Clan</h3>

	<ul>
<li><a href="http://gamebattles.com/profile/clanmoffatt">Clan Moffet</a></li>
<li><a href="http://gamebattles.com/profile/schaplowsky916">schaplowsky916</a></li>
<li><a href="http://gamebattles.com/profile/gameguysz">gameguysz</a></li>
	</ul>
</li>
		
</ul>
		</div>
		<div class="clear"></div>
	</div>
	<div id="footer">
		Version 2 Gaming
     
  

</div>
</div>
</div></div></body>
</html>
2
Contributors
7
Replies
9
Views
8 Years
Discussion Span
Last Post by SKANK!!!!!
0

if ($username&&$password&repassword)

ok... what do i need to do if i make it look like this

if ($username&&password&&repassword) i get this error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/a6027290/public_html/register.php on line 60

if i leave it it says it worked i get no error... But the user information is not sent to mysql

0
if ($username&&password&&repassword)

DOES NOT WORK BECAUSE THERE ISNT A VARIABLE SIGN INFRONT OF THE VARIABLE NAME

if ($username && $password && $repassword)

works. believe me. the code isnt working because the statement way above is wrong so it skips it.

u also dont have to encrypt both of thesem just the one you are storing in the database:

//encrypt password
$password = md5 ($password);
$repassword = md5($repassword);

then u dont need to have a mysql column for repassword since it is going to be the same as password

("INSERT INTO users (username, password) VALUES('$username', '$password')")
0

ummm still nothing... but here is the updated code

<html>

<head profile="http://gmpg.org/xfn/11">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

	<title>Version 2 Gaming</title>

	<meta name="generator" content="WordPress 2.3.1" /> <!-- leave this for stats please -->

	<style type="text/css" media="screen">
		@import url( http://wpmix.com/wpdemos/wp-content/themes/blue_rings/style.css );
	</style>

	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://wpmix.com/wpdemos/?feed=rss2" />
	<link rel="alternate" type="text/xml" title="RSS .92" href="http://wpmix.com/wpdemos/?feed=rss" />
	<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="http://wpmix.com/wpdemos/?feed=atom" />

	<link rel="pingback" href="http://wpmix.com/wpdemos/xmlrpc.php" />
		<link rel='archives' title='August 2007' href='http://wpmix.com/wpdemos/?m=200708' />
	<link rel='archives' title='July 2007' href='http://wpmix.com/wpdemos/?m=200707' />
			<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://wpmix.com/wpdemos/xmlrpc.php?rsd" />
 <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://wpmix.com/wpdemos/wp-includes/wlwmanifest.xml" /> </head>

<body><div id="bodybottom"><div id="bodytop">
<div id="page">
	<div id="header">
		<h1><a href="http://wpmix.com/wpdemos/">Version 2 Gaming</a></h1>
		<h2>Pro's in everything you like to know</h2>
		<ul>
			<li class='current_page_item'><a href="http://www.google.com/">Home</a></li>
			<li class="page_item page-item-2"><a href="http://www.google.com" title="About">About</a></li>

<li class="page_item page-item-3"><a href="http://www.google.com/" title="Contact">Contact</a></li>
		</ul>
	</div>
	<div id="container">
		<div id="content">

<div class="post" id="post-5">
	<h2>Become a member!</h2>

	<div class="entry"> <!--Edit this for the main body on the home page-->
		<p>
<?php
echo "<h1>Register</h1>";

$submit = $_POST['submit'];
$username = strtolower(strip_tags($_POST['username']));
$password = strip_tags($_POST['password']);
$repassword = strip_tags($_POST['repassword']);

if ($submit)
{

 //open database
 $connect = mysql_connect("mysql5.000webhost.com","a6027290_members","m26682668");
 mysql_select_db("a6027290_members"); //select database
 
 $namecheck = mysql_query("SELECT username FROM users WHERE username='$username'");
 $count = mysql_num_rows($namecheck);

 if ($count!=0)
 {
  echo "Username already taken! <a href='register.php'>Retry</a>";
  die ();
 }

 //check for existance
if ($username && $password && $repassword)
{
	
	if ($password==$repassword)
	{
	
	 //check char length of username
	 if (strlen($username)>25)
	 {
	  echo "You username must be under 25 characters in length";
	 }
	 else
	 {
	  
	  //check password length
	  if (strlen ($password)>25||strlen($password)<6)
	  {
	   echo "Password must be between 6 and 25 characters";
	  }
	  else
	  {
	   //register the user 
	   
	   	//encrypt password
		$password = md5 ($password);
	   
	   
	   $queryreg = ("INSERT INTO users (username, password) VALUES('$username', '$password')");
	   
	   die ("You have been registered! <a href='index.html'>Login</a>");
	   
	  }
	 
	 }
	
	}
	else
		echo "Your passwords do not match";
	
}
else
	echo "Please fill in <b>all</b> fields!";
 
}
?>
<html>
<p>
<form action='register.php' method='POST'>
	<table>
		<tr>
			<td>
			Username:
			</td>
			<td>
			<input type='text' name='username' value='<?php echo $username ?>'>
			</td>
		</tr>
		<tr>
			<td>
			Password:
			</td>
			<td>
			<input type='password' name='password'>
			</td>
		</tr>
		<tr>
			<td>
			re Password:
			</td>
			<td>
			<input type='password' name='repassword'>
			</td>
		</tr>
	</table>
	<p>
	<input type='submit' name='submit' value='Register'>
</form>

</html>

		</p>

			</div>

	<div class="comments">
		<a href="gameguysz@yahoo.com" title="Email me for more info">Email</a>	</div>

</div>

    		</div>
		<div id="sidebar">
			<ul>
	</li>
		<li id="linkcat-2" class="linkcat"><h3>V2 Clan</h3>

	<ul>
<li><a href="http://gamebattles.com/profile/clanmoffatt">Clan Moffet</a></li>
<li><a href="http://gamebattles.com/profile/schaplowsky916">schaplowsky916</a></li>
<li><a href="http://gamebattles.com/profile/gameguysz">gameguysz</a></li>
	</ul>
</li>
		
</ul>
		</div>
		<div class="clear"></div>
	</div>
	<div id="footer">
		Version 2 Gaming
     
  

</div>
</div>
</div></div></body>
</html>
0
<?php
echo "<h1>Register</h1>";
if (isset($_POST[submit]))
{$username = strtolower(strip_tags($_POST['username']));
$password = strip_tags($_POST['password']);
$repassword = strip_tags($_POST['repassword']);
//open database
 $connect = mysql_connect("mysql5.000webhost.com","a6027290_members","m26682668");
 mysql_select_db("a6027290_members"); //select database
 $namecheck = mysql_query("SELECT username FROM users WHERE username = '$username'");
if($namecheck){$count = mysql_num_rows($namecheck);}
 if ($count!=0)
 {exit("Username already taken! <a href='register.php'>Retry</a>");}
 //check for existance
if ($username == "" || $password == "" || $repassword == "")
{exit("Please fill in <b>all</b> fields! <a href='register.php'>Retry</a>";}
	if ($password != $repassword)
	{exit("Your passwords do not match <a href='register.php'>Retry</a>");}
	 //check char length of username
	 if (strlen($username)>25)
	 {echo "You username must be under 25 characters in length <a href='register.php'>Retry</a>"; }
	  //check password length
	  if (strlen ($password)>25 || strlen($password)<6)
	  {exit("Password must be between 6 and 25 characters <a href='register.php'>Retry</a>");}
	   //register the user
$password = mysql_real_escape_string($password);
$username = mysql_real_escape_string($username);
	   //encrypt password with sha1 
		$password = sha1($password);
	   $queryreg = mysql_query("INSERT INTO users (username, password) VALUES('$username', '$password')");
if($queryreg){die("You have been registered! <a href='index.html'>Login</a>");}
}
	 

?>
<html>
<p>
<form action='register.php' method='POST'>
	<table>
		<tr>
			<td>
			Username:
			</td>
			<td>
			<input type='text' name='username'>
			</td>
		</tr>
		<tr>
			<td>
			Password:
			</td>
			<td>
			<input type='password' name='password'>
			</td>
		</tr>
		<tr>
			<td>
			re Password:
			</td>
			<td>
			<input type='password' name='repassword'>
			</td>
		</tr>
	</table>
	<p>
	<input type='submit' name='submit' value='Register'>
</form>
0

Sweet man thanks i got it working again!

There was a problem when you made the password sha1

all i had to do was change it to md5 again for my login!

Thanks again man!

0

Sweet man thanks i got it working again!

There was a problem when you made the password sha1

all i had to do was change it to md5 again for my login!

Thanks again man!

sha1 i think is more hard to crack or something. it has i think 40 character and not 32 like i think md5 has

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.