I think this will do for you:
index php.
<form id="form" name="form" method="post" action="envia.php">
Links: <label for="nome"></label>
<textarea name="nome" id="nome" cols="20" rows="8"></textarea>
<input type="submit" name="button" id="button" value="Enviar" />
</form>
<?php
include("conexao.php");
$sql = "SELECT seu_campo FROM sua_tabela";
$result = mysqli_query($conn, $sql);
while ($linha = mysqli_fetch_assoc($result)){
echo "<a href=".$linha['nome'].">".$linha['nome']."</a><br>";
}
?>
In the index.php
, you enter the values in the textarea and then they are shown as link below, after insertion.
php.
<?php
include_once("conexao.php");
$nomes = $_POST['nome'];
$separar = explode("\n", $nomes);
foreach($separar as $nome){
$query = "INSERT INTO sua_tabela (seu_campo) VALUES ('".$nome."')";
$resultado = mysqli_query($conn, $query);
}
echo "Seu cadastro foi realizado com sucesso!";
?>
This is where it does all the separating magic by line breaking using the explode
and then you can enter it into the database.
php connection.
<?php
$servidor = "localhost";
$usuario = "root";
$senha = "1234";
$dbname = "teste";
$conn = mysqli_connect($servidor, $usuario, $senha, $dbname);
?>
And this is the connection file I used, just exchange the value of the variables for your mysql data.
Finally, replace where it says "your table" and "your field" and I believe it will work smoothly.
what’s the idea, what you need, I didn’t understand your question.
– Wictor Chaves
I didn’t understand anything
– Anderson Henrique
how so "register these links on the server"?
– Ricardo Pontual
wanted to register in the database the first part there, and with php returned the second part there, but only taking the first parts of the url that is site1,site2,site3,site4, without the . with, and formatting leaving the way I posted there in the second part creating a link with the first part of the site url
– Rogério Silva
Possible duplicate of How to get the site name?
– Inkeliz