Jump to content

Not inserted to MySQL table;


justinba1010

Recommended Posts

<?php

//Register 1.0.1
include("function.php");
connect();
$num = 0;
if(isset($_POST['submit']))
{

if($_POST['username'] == '' || $_POST['password1'] == '' || $_POST['password2'] == '')
{
	$num = 1;
	echo "Please supply all fields;";
	exit();
}
	elseif(strlen($_POST['username']) > 25)
	{
		$num = 1;
		echo "Username must be under 25 characters long;";
		exit();
	}
	elseif(strlen($_POST['password1']) > 16)
	{

		if(strlen($_POST['password2']) >16)
		{
			$num = 1;
			echo "Password are over 16 characters long;";
			exit();
		}
		$num = 1;
		echo "Passwords are not equal";
		exit();

	}
	elseif($_POST['password1'] != $_POST['password2'])
	{
		$num = 1;
		echo "Passwords are not equal;";
		exit();
	}
}

else 
{
if(isset($_POST['submit']))
{
	$username = $_POST['username'];
	safe($username);
	if($_POST['password1'] = $_POST['password2'])
	{
		$password = $_POST['password'];
		password($password);
		echo "INSERT INTO user (username, password) VALUES ('$username','$password')";
	}
	else {
		echo "Passwords are not equal; Double Take";//Yes Double Take is a military term
		exit();
	}
}
}

?>

<HTML>
<form action="register.php" method="post">
	Username:<input type="text" name="username">
		<br>
	Password:<input type="password" name="password1">
		<br>
	Password Check:<input type="password" name="password2">
		<br>
	<input type="submit" name="submit" value="Register!">	
</HTML>

 

Here is where I put the code:

 

if(isset($_POST['submit']))

{

$username = $_POST['username'];

safe($username);

if($_POST['password1'] = $_POST['password2'])

{

$password = $_POST['password'];

password($password);

echo "INSERT INTO user (username, password) VALUES ('$username','$password')";

}

else {

echo "Passwords are not equal; Double Take";//Yes Double Take is a military term

exit();

}

 

I used it like that to narrow it down. And I still do not understand the issue, are there any other issues?

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

Notice: Undefined index: password in /opt/lampp/htdocs/game/register.php on line 46

INSERT INTO user (username, password) VALUES ('j','')

 

When I changed it to

<?php

//Register 1.0.1
include("function.php");
connect();
$num = 0;
if(isset($_POST['submit']))
{

if($_POST['username'] == '' || $_POST['password1'] == '' || $_POST['password2'] == '')
{
	$num = 1;
	echo "Please supply all fields;";
	exit();
}
	elseif(strlen($_POST['username']) > 25)
	{
		$num = 1;
		echo "Username must be under 25 characters long;";
		exit();
	}
	elseif(strlen($_POST['password1']) > 16)
	{

		if(strlen($_POST['password2']) >16)
		{
			$num = 1;
			echo "Password are over 16 characters long;";
			exit();
		}
		$num = 1;
		echo "Passwords are not equal";
		exit();

	}
	elseif($_POST['password1'] !== $_POST['password2'])
	{
		$num = 1;
		echo "Passwords are not equal;";
		exit();
	}
	$username = $_POST['username'];
	safe($username);
	if($_POST['password1'] == $_POST['password2'])
	{
		$password = $_POST['password'];
		password($password);
		echo "INSERT INTO user (username, password) VALUES ('$username','$password')";
	}
}



?>

<HTML>
<form action="register.php" method="post">
	Username:<input type="text" name="username">
		<br>
	Password:<input type="password" name="password1">
		<br>
	Password Check:<input type="password" name="password2">
		<br>
	<input type="submit" name="submit" value="Register!">	
</HTML>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.