Register aint working! (Not Saving to Database)

As stated in the title, When I’m trying to write into the database… Nothing is being written for some reason…

[php]

Register - Shock Hosting <?php error_reporting (E_ALL ^ E_NOTICE); session_start(); $userid = $_SESSION['userid']; $username = $_SESSION['username']; ?>

<?php
if ($username && $userid)
{
	header('Location: ./Index.php');	
}
else
{
   
$form= "<form action=' ./Register.php' method='post'>		
<table>
<tr>
	<td>Desired Username:</td>
    <td><input type='text' name='user'/></td>
</tr>
<tr>
	<td>Desired Password:</td>
    <td><input type='text' name='password'/></td>
</tr>
<tr>
	<td>Email Address:</td>
   	<td><input type='text' name='email'/></td>
</tr>
<tr>
	<td></td>
    <td><input type='submit' name='loginbtn' value='Login'/></td>
</tr>
</table>
</form>";

if ($_POST['loginbtn']) {
	$user = $_POST['user'];
	$password = $_POST['password'];
	$email = $_POST['email'];
	
	if ($user){
		if($password){
			require("connect.php");
			
			$password = md5(md5("afasg".$password."D123Id"));
			
			//connects to database
			$query = mysql_query("SELECT * FROM Users WHERE Username = '$user'");
			$numrows = mysql_num_rows($query);
			$query2 = mysql_query("SELECT * FROM Users WHERE Email = '$email'");
			$numrows2 = mysql_num_rows($query2);
			
			if ($numrows == 1)
			{
				echo "The desired username is currently taken.";
				
			}
			else
			{
				if ($numrows2 == 1)
				{
					echo "The email address you are trying to use is currently taken.";
					
				}
				else
				{
					$regquery = mysql_query("INSERT INTO Users (Username,Password,Email,active) VALUES ('$username','$password','$email','0'");
					

				}
				
								
			}	
			mysql_close();	
		}
			
		else
		{
			echo "You must enter your password. $form";
		}
	}
	else
	{
		echo "You must enter your username. $form";
	}
}
else
	echo "$form";
}
?></div></div>
	<div id="footer">
	&copy; 2012 Fleming Hosting</div>
</body>
[/php]

Are you getting any errors?

I only found one error.

since you you are processing the data in the same script you don’t need an action in your form.

it should be
[php]
$form= "
[/php]

you have
[php]
$form= "
[/php]

also at the end of the line where you run the query add a die(mysql_error());

like this
[php]
$regquery = mysql_query(“INSERT INTO Users (Username,Password,Email,active) VALUES (’$username’,’$password’,’$email’,‘0’”) or die(mysql_error());
[/php]

that way you know if the query is correct or has errors in it.

oops Matt, I didn’t see your Post i usually don’t repply if someone is already helping.

Feel free :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service