Changing page information with PHP

0

I'm doing a college job and I need to change page information like title-intro , blockquote and quote 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 does not seem to be the correct way, how can I do it in a correct and simple way?

File 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 that 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 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;
}
    
asked by anonymous 23.08.2018 / 16:35

1 answer

-1

The correct way, at first glance, would be with AJAX requests. You would have a JS source making requests for that other page in PHP, capturing the values and updating them.

function ajax() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
     document.getElementById("demo").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "OUTRA-PAGINA.PHP", true);
  xhttp.send();
}
    
23.08.2018 / 18:26