Return message to the registration screen

Asked

Viewed 856 times

0

Guys, I’m a beginner in PHP and I need a help.

I have a.html register that has some fields that calls the.php register that inserts the data into the database and shows the message whether it was successfully inserted or not.

How do I display this message on the registration screen?

I am trying to do as follows, when I click on the "Register" button goes to the.php register and returns to the.html register with the return message (if it was inserted in the database or if it was successfully inserted).

Someone has some light to help me?

inserir a descrição da imagem aqui

4 answers

1


I think you want to make it show a message when it was inserted, you can do so

echo '<script> alert ("Quantidade alterada com sucesso!"); location.href=("cadastro.php")</script>';

0

replace everything with a . php page, with this you can work your html and php in a single file.

ex.:

<?php

if(count($_POST)){
$variavel = $POST["variavel"];

//sua requisição via banco de dados

//se for ok, você retorna a mensagem
}

?>

//seu codigo html aqui

any doubt put the files here

  • And how do you not enter the data when you load the page? http://prntscr.com/lkite9 Every time I update the page it inserts blank data into the database in addition to getting these errors...

0

A file HTML is static, there is no way to mount it using information that you got in the PHP. For that you need a template engine, which by the way, PHP is already a.

For organization purposes you’d better have something like cadastro_controller.php and cadastro.php. A PHP file can contain both PHP and HTML code, so you can use.php to build your HTML, and have access to PHP message simultaneously.

I would like to write how to do this here, but honestly, the process is not so trivial. You can use the require "controler.php" within the cadas_controller.php bring your page to the environment where you have access to the registration result, but this is a hack that does not scale well in large projects. You can use frameworks for this process, Laravel and CodeIgnater are quite popular.

At the end of the process, you’ll have your.php sign-up similar to

<html>
...
<p><?= $menssagem ?></p>
<a>Clique aqui para realizar um novo cadastro</a>
<a>Clique aqui para listar os automóveis</a>
...
</html>

0

Create your form page as php file: cadastro.php Send the form information to another php page: register-inserts.php for example On the register-inserts.php page send the information to the database. Do an insert check and if inserted create a success message Session.

session_start();

if(cadastroInserido()){
  $_SESSION['inserido']="Cadastro inserido com sucesso!";
}

then create a header to go back to the.php sign-up page.

header("location:cadastro.php);
die();

on the.php sign-up page read the Section and then unlink it

if(isset($_SESSION['inserido'])){
echo $_SESSION['inserido'];
unset($_SESSION['inserido']);
}

I think it’s one of the ways to do

Browser other questions tagged

You are not signed in. Login or sign up in order to post.