0
I am doing a College job and in it I need to change page information like title-intro, blockquote and the cite from the page below, but it has to be done through another page as if it were an administrative page the only idea I had was through form and using the POST method, but it doesn’t seem to be the right way, as I can do it in a correct and simple way?
Filing cabinet adm.php
.
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form method="post" action="index.php">
<input type="text" name="titulo" placeholder="Digite o novo título">
<input type="submit" value="Alterar">
</form>
</body>
</html>
My index file I need to change index.php
<?php
$titulo = $_POST["titulo"];
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>Site com PHP</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<section class="intro">
<div class="container">
<h1 class="titulo-intro"><?php echo $titulo ?></h1>
<blockquote class="quote">"não tenha nada em sua casa que você não considere útil ou acredita ser bonito"</blockquote>
<cite>Willian Morris</cite>
</div>
</section>
</body>
</html>
And the CSS
body {
background: #444;
}
.intro {
color: #FFF;
background: url(../img/bg.jpg);
height: 380px;
text-align: center;
}
.titulo-intro {
font-size: 48px;
font-weight: bold;
text-transform: uppercase;
margin-top: 60px;
}
.quote {
width: 32%;
margin: 0 auto;
font-size: 14px;
font-style: italic;
}
.quote::before, .quote::after {
content: "";
display: block;
height: 3px;
width: 60px;
background: #FFF;
margin: 10px auto;
}
Your question seems to me to be quite broad. The idea is you save this data in the database. Hence, through a parameter
$_GET
, you get theid
of what was saved in the table and brings the results to the page.– Wallace Maxters
"but it doesn’t seem to be the right way, "why?
– Woss
I think a good place to start is How to write values to Mysql database with PHP
– Wallace Maxters
It makes no sense to do what you are doing through the POST. You want the admin to publish something, and it reflects in the PHP script, like a template, which contains the same styles, but only varies the data. I think I’d need at least a dB there.
– Wallace Maxters
@Wallacemaxters thanks for the answer, I also see no other alternative to not know use a simple dB here. Thanks even, the link helped me a lot.
– Randys Machado