Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="pt-br">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <?php
- $mysqli = new mysqli('localhost', 'root', '', '0001');
- if ($mysqli->connect_errno) {
- echo 'Erro ao conectar ao banco de dados' . $mysqli->connect_error;
- }
- if ($_POST) {
- if ($nome =$_POST['nome']) {
- $query = "INSERT INTO usuarios (nome,data,horario) values('$nome', NOW(), NOW())";
- $res = $mysqli->query($query);
- if ($res) {
- $mensagem = "Cadastrado com sucesso!";
- header("Location:index.php");
- }
- }
- }
- $res = $mysqli->query("SELECT * FROM usuarios");
- ?>
- <h1>Cadastro rápido de links</h1>
- <h3>Links cadastrados</h3>
- <ul>
- <?php while ($row = $res->fetch_assoc()) { ?>
- <li><a href="<?php echo $row["nome"]; ?>" target="_blank"><?php echo $row["nome"]; ?></a></li>
- <!-- <li> <?php echo $row['nome'] ?></li> -->
- <?php } ?>
- </ul>
- <hr>
- <p>Cadastrar link abaixo: </p>
- <form action="index.php" method="post">
- <label>URL</label>
- <input type="text" name="nome">
- <input type="submit" value="Salvar">
- </form>
- <?php if (!empty($mensagem)) {
- echo $mensagem;
- } ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement