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
https://forums.phpfreaks.com/topic/249579-not-inserted-to-mysql-table/
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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.