Jump to content
player81

Ajutor la zona de commenturi pe site

Recommended Posts

Posted

Salut. Am facut un site (cu greu, ca nu ma prea pricep la PHP) la care in partea de jos trebuie sa-i fac o zona de comenturi si nu stiu cum sa-l fac.

Am nevoie de o portiune unde vizitatorii sa completeze 3 campuri: nume, numar si text; si astea sa apara in jos una dupa alta.

Aveti idee cam cum ar fi un astfel de cod PHP?

Posted (edited)

Baza de date.

cand trimite:

Adaugi intr-un tabel(comments) coloanele: nume numar comment

Cand deschizi pagina:

Din php selectezi toate randurile din baza de date.

si le afisezi in forma

echo("<p>NUME: $nume </p>");

etc.

PM me daca vrei si sursa

Edited by yoyois
Posted

Faci cu phpmyadmin database-ul "site" si table este "comenturi" si la comenturi id auto, nume, numar, text


<?php $sql=mysql_connect('localhost','user','parola');
$db=mysql_select_db('site',$sql); ?>


<?php
$afisezCOMENTURI=mysql_query("SELECT * from comenturi");
while($showCOMENTURI=mysql_fetch_array($afisezCOMENTURI))
{
echo $showCOMENTURI['nume'].'<br>';
echo $showCOMENTURI['numar'].'<br>';
echo $showCOMENTURI['text'].'<br>';
}
?>
<form action="" method="post">
<input type="text" name="nume"><br>
<input type="text" name="numar"><br>
<input type="text" name="text"><br>
<input type="submit" name=""adaug">
</form>
<?php
if(isset($_POST['adaug']))
{
$nume=$_POST['nume'];
$numar=$_POST['numar'];
$text=$_POST['text'];
$bagDATE="INSERT INTO comenturi (id,nume,numar,text)VALUES(0,'$nume','$numar','$text')";
if(mysql_query($bagDATE)){echo 'Succes';}else{echo 'Error';}
}
?>

Posted

Pe intelesul tuturor:

1. Faci inputurile (Nume, Email, Text,etc)

2. Dupa ce a dat trimite, se introduc in MySQL

3. In partea comentariilor extragi din baza de date.

Da-mi PM daca vrei sa-ti fac partea de script.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...