Hello i've got a problem here, i want to insert some data into my table and everything is all right for the first 3 or 4 but the last does not work

<?php

// 
include("config.php");

//
$db_connection = mysql_connect($db_host, $db_user, $db_slaptazodis);
mysql_select_db($db_table, $db_connection);
// 
if ($id == "")
{
	//
	print '
    <form action="' . $PHP_SELF . '?id=jungtis" method="post">
	<table>
        <tr>
	        <td class="markas" align="center">
	            Username:<br/>
	            <input class="text_box" type="text" name="vardas">
	        </td>
        </tr>
        <tr>
	        <td class="markas" align="center">
	        	Password:<br/>
	            <input class="text_box" type="password" name="slaptazodis">
	        </td>
        </tr>
        <tr>
	        <td align="center">
	            <input class="text_box" type="submit" value="Log In">
	        </td>
        </tr>
 <tr>
	        <td class="markas" align="center">
	            <a href="' . $PHP_SELF . '?id=registruoti" class="markas">Registration</a>
	        </td>
        </tr>
       </table>
    </form>';
}

// 
if ($id == "jungtis")
{
	// 
    if($vardas != "" && $slaptazodis != "")
	{
        // 
	    $result = mysql_query("SELECT * FROM `vartotojai` WHERE `vardas` = '$vardas' AND `slaptazodis` = '$slaptazodis' LIMIT 1");

        // 
	    if(mysql_num_rows($result) > 0)
	    {
        	// 
        	print"<b>You have successfully logged in.</b><br/><br/>";

            // 
            $duomenys = mysql_query("SELECT * FROM vartotojai");

            // 
            while ($stulpelis = mysql_fetch_array($duomenys))
            {
            	// Patikrinama ar tikrai vartotojai sutapo:
                if ($stulpelis['vardas'] == $vardas)
                {
                	// Rodoma vartotojo informacija:
                	print" <b><img src='http://feelthat.uphero.com/usersystem/images/" . $stulpelis['avataras'] . "'</b><br/><br>

                               Tavo Duomenys:<br>
                               Vartotojas:<b>" . $stulpelis['vardas'] . "</b><br/>
                               Parasas:<b>" .  $stulpelis['parasas'] . "</b><br/>
                               <a href='?id=sudetis' class='raudona'>Klano sudetis<br/>
                             <a href='registracija_ir_login.php'>Atsijungti</a><br/>
                                 <form action='registracija_ir_login.php?id=funkcija' method='post'>
                                 <fieldset>
                                 <input type='text' value='" . $stulpelis['avataras'] . "' class='text_box' name='avataras'><br/>
                                 </fieldset>
                                 <fieldset>
                                 <input type='submit' class='text_box' value='Registruoti'>
                                 </fieldset>
                                 </form>";

                }
            }

	    }
        else
        {
        	// Jeigu duomenu nerasta:
        	print"Wrong Username or Password.";
        }
	}
    else
    {
    	// Pranesama apie tuscius laukelius:
    	print"Empty fields.";
    }
}


// Lapas registracijos formos:
if ($id == "registruoti")
{
	// Rodi laukeliai info:
	print '
    <form action="registracija_ir_login.php?id=funkcijos" method="post">
	    <table>
	        <tr>
	            <td class="markas" align="center">
	                Username:<br/>
	                <input type="text" class="text_box" name="vardas">
	            </td>
	        </tr>
	        <tr>
	            <td class="markas" align="center">
	                Password:<br/>
	                <input type="password" class="text_box" name="slaptazodis">
	            </td class="markas" align="center">
	        </tr>
	        <tr>
	            <td class="markas" align="center">
	                E-mail:<br/>
	                <input type="text" class="text_box" name="el_pastas">
	            </td>
	        </tr>
                       <tr>
                        <td class="markas" align="center">
                            Character: <input type="checkbox" name="Naruto">
														</td>
                       </tr>
                              <tr>
	            <td class="markas" align="center">
	                Avatar:<br/>
	                <input type="text" class="text_box" name="avataras"><br/>
                        <a href="index.php">Ikelti Avatara</a><br/>
	           	        </tr>
                                             <tr>
	            <td class="markas" align="center">
	                Signature:<br/>
	                <input type="text" class="text_box" name="parasas">
	            </td>
	        </tr>
	        <tr>
	            <td class="markas" align="center">
	                <input type="submit" class="text_box" value="Register">
	            </td>
	        </tr>
                   </table>
    </form>';
}

// Lapas funkcijos kuri itraukia vartotojus:

if ($id == "funkcijos"){
    if($vardas != "" && $slaptazodis != "" && $el_pastas != ""){
        $query = "INSERT INTO vartotojai SET vardas = '$vardas', slaptazodis = '$slaptazodis', el_pastas = '$el_pastas', avataras = '$avataras', parasas = '$parasas'";
        mysql_query($query);
        print "Welcome to the Naruto-Clash. <a href='registracija_ir_login.php'>Log In.</a>";
				
				mysql_close($db_connection);
				
    }else{
	print "Empty fields.";
    }

               
}else{
		//[B]Here[/B]
		
		$handle = mysql_connect('mysql3.000webhost.com', 'a7209154_usersys', '');
		
		if($handle == false){
		   die("Could not connect to MySQL.\r\n");
			 }
			 
	$db = mysql_select_db('a7209154_usersys');
	
	if($db == false){
	     die("Could not select MySQL DB.\r\n");
			 }
			 
			 $query = 'INSERT INTO vartotojai (character, parasas) VALUES ("Naruto, PASSWORD("")';
			 
			 $result = mysql_query($query, $handle);
			 
			 echo ($result) ? "Insert was successful.\r\n" : "Insert was unsuccessful.\r\n";
			 
			 mysql_close($handle);
	
	
}


// Uzdaroma duomenu bazes uzklausa:

?>

So what is the problem? Data is not inserted or you php code gives error?

P.S. Your code is VERY insecure! Please do at least any input data validation and sanitization.

the problem is i dont insert to db

How do you receive the data via form. I see no '$_POST' or '$_GET' or '$_REQUEST'. You wouldn't get any data if you are using the form.

$query = "INSERT INTO vartotojai SET vardas = '$vardas', slaptazodis = '$slaptazodis', el_pastas = '$el_pastas', avataras = '$avataras', parasas = '$parasas'";

Where are '$vardas,$slaptazodis,$el_pastas,$avataras,$parasas' come from ? You must use '$_POST[]' (for post method), '$_GET[]' (for get method), or '$_REQUEST[]' (for both post and get).
It may like:

$vardas = $_POST['vardas'];
$slaptazodis = $_POST['slaptazodis'];
$el_pastas = $_POST['el_pastas'];
$avataras = $_POST['avataras'];
$parasas = $_POST['parasas'];

 if($vardas != "" && $slaptazodis != "" && $el_pastas != ""){
        $query = "INSERT INTO vartotojai SET vardas = '$vardas', slaptazodis = '$slaptazodis', el_pastas = '$el_pastas', avataras = '$avataras', parasas = '$parasas'";
        mysql_query($query);
}

Hope this help.

you see at the beginning include("config.php");
inside config is this
$id = $_GET;
$vardas = $_POST;
$el_pastas = $_POST;
$slaptazodis = $_POST;
$avataras = $_POST;
$parasas = $_POST;
$character = $_POST;

and also i need the last one not the one that you fixed :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.