Stefce 146 Posting Pro

Dont work again :/
Here at values

 VALUES (?, ?, ?, ?)");

does it need to be like that or i need to change it ?
Also where to put that $pw = hash ?

Stefce 146 Posting Pro

Yeah they are not the real, i'm using other, im just changing for the security reasons ...

Stefce 146 Posting Pro

My whole registration script if you can make changes here so ill just copy and paste to test it :/ THANK YOU

<html>
<body bgcolor='red'>
<title>Register</title>
<style>
    font.position_font {
        position:absolute;
        left:20%;
    }
    input.new_account {
        position:absolute;
        left:20%;
        top:80%;
    }
</style>
<form>
<font size="6">
    <div style="opacity:1; position:absolute; border-radius:30px; width:30%; left:20%; top:20%; height:50%; background-color:white; border:10px solid gray;">
        <strong>
            <center>
                <font face='Comic Sans MS' color='blue'>Register</font>
                <hr>
                <font size='3' color='black' class='position_font'>
                <form method='post'>
                    Name: <input type="text" name="name" color='#4DFF4D' placeholder='Your Real Name' /><br>
                    Last Name: <input type="text" name="lastname" color='#4DFF4D' placeholder='Your last name' /><br>
                    Username: <input type="text" name="username" color='#4DFF4D' placeholder='Choose Username' /><br>
                    Password: <input type="password" name="password" color='#4DFF4D' placeholder='Choose Password' /></font>
                    <input style="border-radius:8px;" type="image" class="new_account" name="submitb" src="NewAccount.png" alt="NewAccount" height='50' width='250px'>
                </form>
                <?php
                    if(isset($_POST['name']) && isset($_POST['lastname']) && isset($_POST['username']) && isset($_POST['password']))
                    {
                        $con=mysqli_connect("MyHost","MyUser","MyPass","MyDB");
                        if (mysqli_connect_errno())
                        {
                            echo "Failed to connect to MySQL: ".mysqli_connect_error();
                        }
                        $stmt = mysqli_prepare($con, "INSERT INTO `Members` (`Name`, `Lastname`, `Username`, `Password`) VALUES (?, ?, ?, ?)");
                        mysqli_stmt_bind_param($stmt, 'ssss', $_POST[name], $_POST[lastname], $_POST[username], $_POST[password]);
                        mysqli_stmt_execute($stmt);

                        if (!mysqli_query($con,$stmt))
                        {
                            die('Error: '.mysqli_error($con));
                        }
                        mysqli_close($con);
                    }
                    ?>
        </strong>
    </div>
</font>
</form>
</body>
</html>
Stefce 146 Posting Pro

I have maked some changes but still cannot read into database .. :/

<?php
                    if(isset($_POST['name']) && isset($_POST['lastname']) && isset($_POST['username']) && isset($_POST['password']))
                    {
                        $con=mysqli_connect("MyHost","MyUser","MyPass","MyDB");
                        if (mysqli_connect_errno())
                        {
                            echo "Failed to connect to MySQL: ".mysqli_connect_error();
                        }
                        $stmt = $mysqli->prepare("INSERT INTO `Members` (`Name`, `Lastname`, `Username`, `Password`) VALUES (?, ?, ?, ?)");
                        $stmt->bind_param('ssss', $_POST[name], $_POST[lastname], $_POST[username], $_POST[password]);
                        $stmt->execute();

                        if (!mysqli_query($con,$stmt))
                        {
                            die('Error: '.mysqli_error($con));
                        }
                        mysqli_close($con);
                    }
                    ?>
Stefce 146 Posting Pro

Actually this line

 $con=mysqli_connect("$mysql_host","$mysql_database","$mysql_password ","$mysql_user ");

is good i just change the values for the forum post.

Stefce 146 Posting Pro

Hello everyone, im trying to make a registration system with PHP and MySQL but im not going well i just created table and i have writed the code well but there is something wrong the inputs don't send that data into database i have tryed much different ways of doing it but still cant be posted nothing in to database. Here is the code:

<form method='post'>
                    Name: <input type="text" name="name" color='#4DFF4D' placeholder='Your Real Name' /><br>
                    Last Name: <input type="text" name="lastname" color='#4DFF4D' placeholder='Your last name' /><br>
                    Username: <input type="text" name="username" color='#4DFF4D' placeholder='Choose Username' /><br>
                    Password: <input type="password" name="password" color='#4DFF4D' placeholder='Choose Password' /></font>
                    <input style="border-radius:8px;" type="image" class="new_account" name="submitb" src="NewAccount.png" alt="NewAccount" height='50' width='250px'>
                </form>
                <?php
                    if(isset($_POST['name']))
                    {
                        $con=mysqli_connect("$mysql_host","$mysql_database","$mysql_password ","$mysql_user ");
                        if (mysqli_connect_errno())
                        {
                            echo "Failed to connect to MySQL: ".mysqli_connect_error();
                        }
                        $sql="INSERT INTO Members (Name, Lastname, Username, Password)
                        VALUES
                        ('$_POST[name]','$_POST[lastname]','$_POST[username]','$_POST[password]')";
                        if (!mysqli_query($con,$sql))
                        {
                            die('Error: '.mysqli_error($con));
                        }
                        mysqli_close($con);
                    }
                    ?>

Thank you for helping me !

Stefce 146 Posting Pro
    <font color='#4DFF4D'><form style='position:center' method='get' align='left'>
            <input type='checkbox' name='prasok' value='prasok'/> -> Prasak = 200 <font color='red'>DENARI</font>
        <br>
            <input type='checkbox' name='salama' value='salama'/> -> Salama (500g) = 150 <font color='red'>DENARI</font>
        <br>
            <input type='checkbox' name='banani' value='banani'> -> Banani (1kg) = 80 <font color='red'>DENARI</font>
        <br>
            <input type='checkbox' name='sol' value='sol'/> -> Sol = 60 <font color='red'>DENARI</font>
        <br>
            <input type='checkbox' name='vegeta' value='vegeta'/> -> Vegeta = 100 <font color='red'>DENARI</font>
        <br>
            <input type='checkbox' name='zejtin' value='zejtin'/> -> Zejtin = 70 <font color='red'>DENARI</font>
        <br>
            <input type='checkbox' name='paketce' value='paketce'/> -> Novogodisno paketce = 199 <font color='red'>DENARI</font>
        <br>
            <input type='checkbox' name='amasina' value='amasina'/> -> Masina za perenje alista = 9999 <font color='red'>DENARI</font>
        <br>
            <input type='checkbox' name='smasina' value='smasina'/> -> Masina za perenje sadovi = 4999 <font color='red'>DENARI</font>
        <br>
            <input type='checkbox' name='mikrobranova' value='mikrobranova'/> -> Mikrobranova pecka = 3999 <font color='red'>DENARI</font>
        <br>
            <button type='submit'>Buy Products</button>
            <b>Total: </b>
            <?php
            $prices = array (
                'mikrobranova' => 3999,
                'smasina' => 4999,
                'amasina' => 9999,
                'sol' => 60,
                'prasok' => 200,
                'salama' => 150,
                'banani' => 80,
                'vegeta' => 100,
                'zejtin' => 70,
                'paketce' => 199
            );
                $sum = array();
                $getkeys = array_keys($_GET);
                foreach($prices as $key => $value) {
                    if(in_array($key, $getkeys)) $sum[] = $value;
                }

                if ($_GET['prasok'] == 'prasok') {
                    echo array_sum($sum).' den.';
                } else if($_GET['salama'] == 'salama') {
                    echo array_sum($sum).' den.';
                } else if($_GET['banani'] == 'banani') {
                    echo array_sum($sum).' den.';
                } else if($_GET['sol'] == 'sol') {
                    echo array_sum($sum).' den.';
                } else if($_GET['vegeta'] == 'vegeta') {
                    echo array_sum($sum).' den.';
                } else if($_GET['zejtin'] == 'zejtin') {
                    echo array_sum($sum).' den.';
                } else if($_GET['paketce'] == 'paketce') {
                    echo array_sum($sum).' den.';
                } else if($_GET['amasina'] …
Stefce 146 Posting Pro

Hello since cereal helped me out with the price and counting in PHP i need just one more thing, to get the names of the products i have tryed different ways to do it by my self but i just cant cause im begginer with PHP language, i have this array:

$names = array (
    "mikrobranova" => "Mikrobranova pecka",
    "smasina" => "Masina za sadovi",
    "amasina" => "Masina za alista",
    "sol" => "Sol",
    "prasok" => "Prasak za perenje",
    "salama" => "Salama",
    "banani" => "Banani",
    "vegeta" => "Vegeta",
    "zejtin" => "Zejtin",
    "paketce" => "Novogodisno paketce"
);
$_SESSION['prducts_and_names'] = print($names);

So i need when ill press the "BUY BUTTON" to show me the products i have "checked" on the checkboxes.
Thanks :)

Stefce 146 Posting Pro

Thank you cereal your the best ! :D

Stefce 146 Posting Pro

Thank you again but i need to show the products on kosnica.html u dont need to write the code just give me some exsample on how to continue cause i dont know how to connect the classes in php and how to make the products show in the other page, sorry if im poor with this questions but i need to do for college work :/

Stefce 146 Posting Pro

I actualy want to ask what i need to do that does need some database or it can be done with out it, cause when ill click "Kosnica" count is beeing reseted ?

Stefce 146 Posting Pro

Thank you this works, but now if i want to go the products in "kosnica.html" page how can i do that ?
Here is the website i want to do that: http://secretchatsk.host56.com/

Stefce 146 Posting Pro

Actualy i want to count the products that are selected and to archive into "Kosnica"

Stefce 146 Posting Pro

Well i actualy need another help with making "Shoping Card" so for every checkbox is checked to go into ( "Kosnica" == "Shoping Card" ) i have this code but doesnt add +1 on every checkbox...

<form method='get'>
    <style>
        p.pos_fixed 
        {
            position:fixed;
            top:70px;
            right:250px;
        }
    </style>
    <a href="kosnica.html"><p class="pos_fixed"><b>Kosnica 
    <?php
        $num = 0;
        if ($_GET['prasok'] == 'prasok') {
                echo '( '.($num++).' )';
            } else if($_GET['salama'] == 'salama') {
                echo '( '.($num++).' )';
            } else if($_GET['banani'] == 'banani') {
                echo '( '.($num++).' )';
            } else if($_GET['sol'] == 'sol') {
                echo '( '.($num += 1).' )';
            } else if($_GET['vegeta'] == 'vegeta') {
                echo '( '.($num += 1).' )';
            } else if($_GET['zejtin'] == 'zejtin') {
                echo '( '.(++$num).' )';
            } else if($_GET['paketce'] == 'paketce') {
                echo '( '.(++$num).' )';
            } else if($_GET['amasina'] == 'amasina') {
                echo '( '.(++$num).' )';
            } else if($_GET['smasina'] == 'smasina') {
                echo '( '.(++$num).' )';
            } else if($_GET['mikrobranova'] == 'mikrobranova') {
                echo '( '.(++$num).' )';
            } else {
                echo '( '.(0).' )';
            }
    ?>
    </b></p></a>

</form>

Or also like you can see i have created local class for "Shoping Card" (kosnica.html) so if is possible to work from there and when you will click that to show the products ...

Thanks again and sorry if im wrong with posting here another different queston on this section. :)

Stefce 146 Posting Pro

THANK YOU !!! :D

Stefce 146 Posting Pro

Hello, i'm new in PHP so i dont know much about it so ill need a little help with this "eazy" problem. I need to calculate the total price of the items on every "checkbox" check. here is my code:

<?php
            $mikrobranova = 3999;
            $smasina = 4999;
            $amasina = 9999;
            $sol = 60;
            $prasok = 200;
            $salama = 150;
            $banani = 80;
            $vegeta = 100;
            $zejtin = 70;
            $paketce = 199;
            if ($_GET['prasok'] == 'prasok') {
                echo $prasok;
            } else if($_GET['salama'] == 'salama') {
                echo $salama;
            } else if($_GET['banani'] == 'babani') {
                echo $banani;
            } else if($_GET['sol'] == 'sol') {
                echo $sol;
            } else if($_GET['vegeta'] == 'vegeta') {
                echo $vegeta;
            } else if($_GET['zejtin'] == 'zejtin') {
                echo $zejtin;
            } else if($_GET['paketce'] == 'paketce') {
                echo $paketce;
            } else if($_GET['amasina'] == 'amasina') {
                echo $amasina;
            } else if($_GET['smasina'] == 'smasina') {
                echo $smasina;
            } else {
                echo '0';
            }
        ?>

Thank you for the assisteding. :)

Stefce 146 Posting Pro

ahh cmon guys i need this :S

Stefce 146 Posting Pro

oh god why noone is answering ? :S

Stefce 146 Posting Pro

look i need to make every second the health to go down by "1" after going the health under 20 or is equal to 20 to show the "alertDialog" i dont have any errors. The problem is after the "Health" passed the border/limit the application is cryshing i dont know why is that happening, is there someone to help me with it ?
I also make sure that there is one time show of the "alertDialog" with boolean but doesnt help...
Thanks in advice :)

Stefce 146 Posting Pro

Anyone ? :S

Stefce 146 Posting Pro

Oh gj for the site ! O_O

Stefce 146 Posting Pro

why my app is crushing after passing the seconds ?

new Timer().schedule(new TimerTask() {

            @Override
            public void run() {
                Health -= 1;
                if(Health <= 20) {
                    if (!canSeeWarnDialog) {
                        final AlertDialog alertDialog2 = new AlertDialog.Builder(MainActivity.this).create();
                        alertDialog2.setTitle("Im hungry");
                        alertDialog2.setMessage("The dog health is going low " +
                                "\ngive him some food");
                        alertDialog2.setButton("Got it", new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            }
                        });
                        alertDialog2.show();
                        canSeeWarnDialog = true;
                        return;
                    }
                }
            }
        }, 0, TimeUnit.SECONDS.toMillis(1));