JorgeLuzz Posted May 20, 2020 at 11:28 AM Report Share #618167 Posted May 20, 2020 at 11:28 AM require('db.php'); include("auth.php"); $status = ""; if(isset($_POST['new']) && $_POST['new']==1) { $id=$_REQUEST['id']; $date = $_REQUEST['data']; $login_id =$_REQUEST['login_id']; $submittedby = $_SESSION["username"]; $query="INSERT into 'clientes' ('id',`login_id`,`data`,'submittedby') values ('$id','$login_id','$date','$submittedby')"; $result = mysqli_query($con, $query) or die ( mysqli_error()); $row = mysqli_fetch_assoc($result); $status = "Novo registo inserido com sucesso.</br></br><a href='view.php'>Ver Registos</a>"; } ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Inserir Registo</title> <link rel="stylesheet" href="css/style.css" /> </head> <body> <div class="form"> <p><a href="dashboard.php">Dashboard</a> | <a href="view.php">Ver Registos</a> | <a href="logout.php">Logout</a></p> <div> <h1>Insert New Record</h1> <form name="form" method="post" action=""> <input type="hidden" name="new" value="1" /> <p><input type="text" name="id" placeholder="Numero de conta" obrigatorio /></p> <p><input type="text" name="login" placeholder="Numero de conta" obrigatorio /></p> <p><input type="text" name="date" placeholder="data" obrigatorio /></p> <p><input name="submit" type="submit" value="Submit" /></p> </form> <p style="color:#FF0000;"><?php echo $status; ?></p> <br /><br /><br /><br /> Gera um erro ao inserir na tabela Notice: Undefined index: data in C:\xampp\htdocs\Gestao\insert.php on line 14 Notice: Undefined index: login_id in C:\xampp\htdocs\Gestao\insert.php on line 15 Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\Gestao\insert.php on line 18 Alguem me dá ajuda, Cumprimentos Link to comment Share on other sites More sharing options...
Rui Carlos Posted May 21, 2020 at 10:34 AM Report Share #618182 Posted May 21, 2020 at 10:34 AM Confirma os ids que estás a usar para enviar e processar dados. Por exemplo, tens $_REQUEST['data'], mas foi mesmo data que usaste no form ao enviar os dados? Quanto ao problema do mysqli_error(), confirma se está a passar à função os parâmetros definidos na documentação. Rui Carlos Gonçalves Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now