I saw that your question is in little detail so that we can help you, so that we can give the best solution for you it is necessary to at least understand the purpose of what you are asking... want to create a page on your server (save a .PHP file in it) or only a default page (for example.php profile) where the content will be filled according to the 'user' indicated in the link?
I BELIEVE that the second case is what you are looking for, in which case you create a page where it will be filled with content that is in your bank, for example:
When accessing.php profile you will see a home page with the profiles and buttons as you mentioned, and when you click a button you will be redirected to.php profile? u=marciosx
In this case the profile page.php will verify that the u variable (user but you can put anything) has been filled and will perform a search in your database.
There you must create a table with the fields you need (name, username, photo, other content you want) and the site will search for example the line that has the 'username' = 'marciosx' and finding this line you can put the information you want on the site.
I’ll leave below some scripts for you but in case that’s not what you want to return with more details so we can help you ok. Big hug.
<!--PRIMEIRO TERÁ QUE FAZER A CONEXAO COM O BANCO CRIANDO A PÁGINA conexao.php QUE ESTÁ ABAIXO-->
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conexao = "";
$database_conexao = "";
$username_conexao = "";
$password_conexao = "";
$conexao = mysql_pconnect($hostname_conexao, $username_conexao, $password_conexao) or trigger_error(mysql_error(),E_USER_ERROR);
?>
Now just include the related page.php at the beginning ok.
<? include('conexao.php'); ?>
After that you will check whether the variable 'u' has been specified or not.
<? if(isset($_GET['u'])){<!--Aqui será o código para o caso da variável ter sido indicada-->}
else{<!--Aqui será o código quando não houve variável indicada, ou seja, a página padrão mesmo ou simplesmente um redirecionamento para uma outra página como index.php ou qualquer outra. Aqui vou deixar um redirecionamento para sua página index.php ok-->
echo "<meta HTTP-EQUIV='Refresh' CONTENT='0; URL=index.php'>";
} ?>
Well, as the doubt is about presenting the user data I’ll go straight to this part... let’s search in the database the user marciosx ok.
This will be inside the IF field which is the code for when the variable is indicated that I commented above ok.
$usuario = $_GET['u'];
$sql = mysql_query("SELECT * FROM perfis WHERE usuario = '$usuario' ");
Now that we find they will take the content created by him for example, that you will define because in the question it was not clear what will be presented in this 'link'.
while($linha = mysql_fetch_array($sql)){
$nome = $linha['nome']; <!--Aqui pegamos o conteúdo do campo NOME de seu banco e deixamos 'salvo' na $nome. Faça isso para todos os campos como foto, descrição, página do facebook ou qualquer outra coisa que queira apresentar na sua página ok.-->
$foto = $linha['foto'];
$usuario = $linha['usuario'];
}
Well, now it’s just you build a 'standard' page that will be pretty much the same for all users who 'create a page' on your site, only that the content will be populated according to the content of the bank.
By posting a photo like this:
<img src="img/fotodeperfil.jpg" width="100"/>
Place:
<img src="<? echo $foto; ?>" width="100"/>
So the photo will always be the one informed by the user when 'created' the page understood... the link of the photo will be saved in the bank along with your username, email, description, or any other content.
You can put a default value in case the user does not want to report any photo at that time (if nothing is reported save img/fotodeperfil.php for example).
Okay, so you can already take the content of the page through the link and assemble the way you need, now as for the form you should just take the content and save in the bank, if you do not know how to do this follows below:
<form id="cadastro" method="post" action="salvarCadastro.php">
<input name="nome" type="text" />
<input name="usuario" type="text" />
<input name="foto" type="text" />
<input type="submit" value="Enviar" />
</form>
In this example form we took 3 fields (name, user and photo) and now we will create the save pageCadastro.php to include this in the database, remembering that you will need the connection to the database at the beginning also ok.
<?
include('conexao.php');
$insertSQL = sprintf("INSERT INTO perfis (id, nome, usuario, foto) VALUES (%s, %s, %s, %s)",
GetSQLValueString("a", "text"),
GetSQLValueString($_POST['nome'], "text"),
GetSQLValueString($_POST['usuario'], "text"),
GetSQLValueString($_POST['foto'], "text"));
mysql_select_db($database_conexao, $conexao);
$Result1 = mysql_query($insertSQL, $conexao) or die(mysql_error());
echo "<meta HTTP-EQUIV='Refresh' CONTENT='0; URL=index.php?u=". $usuario ."'>";
?>
Note that when entering the values to be saved in the bank the first one is "a" because it will be the ID of your bank that is usually a numeric value and that is saved automatically because it is the primary key, then stating "a" the bank will disregard this and put the next number of the ok sequence. You know how to create tables in the bank?
Well... so far we already have the form to save the user in the bank 'creating your page'... the page that will present the user content and what is missing is only the buttons with the link of each user, it depends on how you will do, want to open a page with ALL bank users?
Then you can use the famous recordset, I will leave a dry script below (just adjust to stay the way you will need ok).
<?
$maxRows_rsUsuarios = 9999; //Aqui é o limite de resultados que deseja, se colocar 10 serão apresentados somente os 10 primeiros (ou últimos dependendo da forma que definir) resultados.
$pageNum_rsUsuarios = 0; // Se precisar paginar sugiro pesquisar um pouco mais sobre isso para fazer de forma adequada ou fazer uma nova pergunta no site.
if (isset($_GET['pageNum_rsUsuarios'])) {
$pageNum_rsUsuarios = $_GET['pageNum_rsUsuarios'];
}
$startRow_rsUsuarios = $pageNum_rsUsuarios * $maxRows_rsUsuarios;
mysql_select_db($database_conexaomural, $conexaomural);
$query_rsUsuarios = "SELECT * FROM perfis ORDER BY id DESC"; //Aqui eu defini a ordem por ID - ou seja, ordem que as páginas foram criadas - sendo que pode colocar a ordem do mais novo para mais antigo ou o inverso (DESC ou ASC). Assim está o mais novo primeiro ok. Você pode ordenar por nome em ordem alfabetica também, fazendo assim (ORDER BY usuario ASC)
$query_limit_rsUsuarios = sprintf("%s LIMIT %d, %d", $query_rsUsuarios, $startRow_rsUsuarios, $maxRows_rsUsuarios);
$rsUsuarios = mysql_query($query_limit_rsUsuarios, $conexaomural) or die(mysql_error());
$row_rsUsuarios = mysql_fetch_assoc($rsUsuarios);
if (isset($_GET['totalRows_rsUsuarios'])) {
$totalRows_rsUsuarios = $_GET['totalRows_rsUsuarios'];
} else {
$all_rsUsuarios = mysql_query($query_rsUsuarios);
$totalRows_rsUsuarios = mysql_num_rows($all_rsUsuarios);
}
$totalPages_rsUsuarios = ceil($totalRows_rsUsuarios/$maxRows_rsUsuarios)-1;
$queryString_rsUsuarios = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_rsUsuarios") == false &&
stristr($param, "totalRows_rsUsuarios") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_rsUsuarios = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_rsUsuarios = sprintf("&totalRows_rsUsuarios=%d%s", $totalRows_rsUsuarios, $queryString_rsUsuarios);
?>
Now that the code has already picked up all the users of the bank is just you choose the location of the site that they will appear on... can put this on a list (which can be very extensive depending on the amount of registration so you will need to use paging) or even use a div to scroll, using the overflow scroll where all the results will be inside it and the user can scroll the results, if you open Whatsapp Web you will see that the last conversations are fixed in the left corner of the screen and you support the mouse there and scroll down moving only what is inside that div without affecting the rest of the page, would be more or less this, but it doesn’t need to be fixed in the left corner, you can put it anywhere on the page you want, for example.
<div style="overflow:scroll; width:350px; height:550px; border:1px solid #F2F2F2">
</div>
Now let’s put inside this content div with ALL users of ok bank.
<div style="overflow:scroll; width:350px; height:550px; border:1px solid #F2F2F2">
<?php do { ?>
<!--NESSE TRECHO FICARÁ A REPETIÇÃO DE TODOS OS CADASTROS OK-->
<?php } while ($row_rsUsuarios = mysql_fetch_assoc($rsUsuarios)); ?>
</div>
The code for repetition is this above now let’s assemble an example ok:
<div style="overflow:scroll; width:350px; height:550px; border:1px solid #F2F2F2">
<?php do { ?>
<div style="width:300px; margin-left:25px; margin-right:25px; margin-bottom:10px; margin-top:10px">
<table border="0" cellpadding="0" cellspacing="0">
<tr valign="middle">
<td width="120" align="left">
<img src="<?php echo $row_rsUsuarios['foto']; ?>" width="100" />
</td>
<td>
Usuário: <?php echo $row_rsUsuarios['usuario']; ?> - <a href="perfil.php?<?php echo $row_rsUsuarios['usuario']; ?>">Clique aqui</a> para acessar a página desse usuário.
</td>
</tr>
</table>
</div>
<?php } while ($row_rsUsuarios = mysql_fetch_assoc($rsUsuarios)); ?>
</div>
That is, the form saves the data 'creating the page' of the user, the code above shows ALL users who have a 'page' on their site and when clicking on the link will open the profile page.php already stating the variable "u" that would be the page of that user ok.
Now just adapt the code with the data you need and assemble it within your site (I did not worry about appearance of course, I put the dry code ok, then you’ll mount nicely with a good layout).
I hope I’ve helped and hope that’s what you’ve been looking for.
If the question has been deactivated, it is because it was not correct. Answering it will only cause it to be deactivated again. If you wanted to help the user, you could have commented on the problems with the question and how it should improve, and maybe vote negative... You could also search outside the community or in the chat.
– mau humor
Hello Leandro, all right? So even pasting the answer I think your question is not clear. Could you add to the question some details you added to the answer? So you could get other answers from people who think differently than you. It is normal in such questions to know new ways to solve the same problem. xD
– Randrade
I think it’s even cool to make some fun as you did in the reply (as long as it’s not an attempt at irony, of course), I even think it lacks a little more of that relaxation on the site. But that is not without improving the question. By improving the question, you’ll be really helping others with the answer as well, and that’s something to be encouraged (with votes included). But all part of the question self-sufficient and complete so that anyone with expertise in the proposed theme can answer without guesswork. So, is the suggestion of [Edit] with what was asked, to be cool.
– Bacco
In the current form only the author can answer the question because it is not specific.
– Maniero