[PHP] Perché non funziona ?

Vittorio02

Nuovo Utente
20 Mag 2018
5
0
1
Newrow.php :

PHP:
<?php
    include("html/newrow.html");
    
    if(isset($_GET['account'])){
        $account =$_GET['account'];
    }
    
    if(isset($_POST['add'])){   
        $newsite=$_POST['newsite'];
        $newpassword=$_POST['newpassword'];
        $newemail=$_POST['newemail'];
                    
        if(empty($newsite) or empty($newpassword) or empty($newemail)){
            echo "! INSERT ALL DATA !";
        }
        else{
            $database =mysqli_connect('localhost','root','','passwordb');
            $insertquery = "INSERT INTO $account (`site`, `password`, `email`) VALUES ('$newsite', '$newpassword', '$newemail')";
            $queryresult = mysqli_query($database, $insertquery) or die(mysqli_error($database));
            mysqli_close($database);
        }   
    }   
    else{
        echo "";
    }
?>

newrow.html :

HTML:
<html>   
    <head>
        <title>Add a new account</title>
        <link rel="stylesheet" href="css/style.css">
        <link rel="icon" href="plus.jpg" type="image/x-icon" />
    </head>
    
    <body>
        <p>
            <img src="plus.jpg" align="left" width="50px" height="50px">
            <h1><b><i>Add a new account</i></b></h1>
        </p>   
        <div class="input">
            <form action="Newrow.php" method="post">
                <br>New Site/Account: <input type="text" name="newsite">
                <br>New Password: <input type="text" name="newpassword">
                <br>New Username/email: <input type="text" name="newemail">
                <br><br><input type="submit" name="add" value="+Add">
            </form>
        </div>
        <br>
        <br>
        <a href="index.php"><button> YourPassword</button></a>
    </body>
    
</html>
Dopo aver inserito i dati (ad esempio Facebook *** e ***) e cliccato sul submit questo è l'errore che appare :

Undefined variable: account in ... Newrow.php on line 18
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(`site`, `password`, `email`) VALUES ('Facebook', '***', '***'' at line 1