Jump to content

Shout Box In Php (tutorial)


Acrono

Recommended Posts

Trebuie facut cate un fisier separat.

conect.php


<?

mysql_connect("localhost", "username", "password");

mysql_select_db("nume_baza_date");

?>
shout.php

<iframe marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 

src="shoutbox/coment.php" width="100%" height="200">

Shout box-ul nu este găsit... Ne pare rău!!!</iframe>
coment.php
<?

include("conect.php");

$sqlc="select * from chat order by data desc limit 0,8";

$res=mysql_query($sqlc);

?>

<head><Style type="text/css">

body,p,a {font-family:verdana,arial,sans-serif; font-size:10px; text-align:justify;}

input {background:background-color; background-color:#ececec; font-family:verdana,arial,sans-serif; font-size:10px; }

b {font-family:verdana,arial,sans-serif; font-size:11px;}

a {font-family:Times new roman, times, sans-serif;font-size:12px; color:#336699;}

body {margin:0 0 0 0}

</style></head><body bgcolor="#88b6e7">

<center><hr><h2>Shout Box</h1>

{| cellpadding="0" cellspacing="0"

|-----

|

<?

while ($rowc=mysql_fetch_array($res)) {


print '<b><img src="led.gif">';

if ($rowc['email']!='')

{

print '<a href="http://'.$rowc['email'].'">';

}

print $rowc['nume'].'</a> : </b><p>'.$rowc['mesaj'].'</p>';

$ip=$_SERVER['REMOTE_ADDR'];

$ipuser=$rowc['ip'];

if ($ip==$ipuser)

{

print '<h6 align="right"><a href="erase.php?msg='.$rowc['data'].'">Şterge msg-</a></h6>';

}

print '<hr width="80%">';

}

?>

|-----

| align="center" bgcolor="#cecece" |

<form method="POST" name="chat" action="rw.php">

<input value="Nume:" onFocus="document.chat.nume.value=''" size=40 maxlength=40 name="nume"><br><input size=40 value="URL:" onFocus="document.chat.mail.value=''" maxlength=40 name="mail"><br><input value="Mesaj:" onFocus="document.chat.mesaj.value=''" size=40 maxlength=150 name="mesaj"><br><input type="submit" value=">>"><input type="reset" value="Resetează"><br><center><a href="archiv.php" target="_blank">::Arhiva</a> - <a href="smile.php">Smiles::</a></center>

</form>

|}</center>

</body>
rw.php
<?

include("conect.php");



$nume=strip_tags($_POST['nume']);

$mail=strip_tags($_POST['mail']);

$mesaj=strip_tags($_POST['mesaj']);


$mail=str_replace("E-mail:","",$mail);

$mesaj=str_replace(":)",'<img src="smiles/happy.gif">',$mesaj);

$mesaj=str_replace(":D",'<img src="smiles/haha.gif">',$mesaj);

$mesaj=str_replace(":d",'<img src="smiles/haha.gif">',$mesaj);

$mesaj=str_replace(":(",'<img src="smiles/sad.gif">',$mesaj);

$mesaj=str_replace(";)",'<img src="smiles/eye.gif">',$mesaj);

$mesaj=str_replace(":[",'<img src="smiles/mad.gif">',$mesaj);

$mesaj=str_replace(":o",'<img src="smiles/o.gif">',$mesaj);

$mesaj=str_replace(":O",'<img src="smiles/o.gif">',$mesaj);

$mesaj=str_replace(":0",'<img src="smiles/o.gif">',$mesaj);

$mesaj=str_replace(":]",'<img src="smiles/ok.gif">',$mesaj);

$mesaj=str_replace(":p",'<img src="smiles/toung.gif">',$mesaj);

$mesaj=str_replace(":P",'<img src="smiles/toung.gif">',$mesaj);

$mesaj=str_replace(":thanx:",'<img src="smiles/thank.gif">',$mesaj);

$mesaj=str_replace("thank",'<img src="smiles/thank.gif">',$mesaj);

$mesaj=str_replace("putem_face_si_cenzura",'***********',$mesaj);


if ($mail=="URL:")

{

$mail="";

}

if ($mail=="url:")

{

$mail="";

}

$ip=$_SERVER['REMOTE_ADDR'];

$sql="insert into chat(email,nume,mesaj,ip) values('".$mail."','".$nume."','".$mesaj."','".$ip."')";

mysql_query($sql);

header("location: coment.php");

?>
erase.php
<?

include("conect.php");

$data=$_GET['msg'];

$sqlcc="delete from chat where data='".$data."'";

mysql_query($sqlcc);

header("location: coment.php");

?>
archiv.php

<?

include("conect.php");

$sqlc="select * from chat";

$res=mysql_query($sqlc);

?>

<head><Style type="text/css">

body,p,input {font-family:verdana,arial,sans-serif; font-size:10px;}

b {font-family:verdana,arial,sans-serif; font-size:11px;}

a {font-family:Times new roman, times, sans-serif;font-size:12px; color:#336699;}

</style><title>Shoutbox :: Arhiva</title></head><body>

<center><h1><img src="led.gif">ShoutBox<img src="led.gif"></h1></center><hr width="95%"><hr width="97%"><hr>

<?

while ($rowc=mysql_fetch_array($res)) {


print '<b><a href="mailto:'.$rowc['email'].'">'.$rowc['nume'].'</a> : </b><p>'.$rowc['mesaj'].'</p><h6 align="right">'.$rowc['data'].'</h6><hr>';

}

?>
smile.php
<head><Style type="text/css">

body,p,a,input {font-family:verdana,arial,sans-serif; font-size:10px;}

b {font-family:verdana,arial,sans-serif; font-size:11px;}

a {font-family:Times new roman, times, sans-serif;font-size:12px; color:#336699;}

body {margin:0 0 0 0}

</style></head><body>

{| width="100%" bgcolor="#c0c0c0" border="0" cellpadding="0" cellspacing="0"

|-----

|

{| width="100%" bgcolor="#cecece" border="1" frame="void" cellpadding="0" cellspacing="0"

|-----

|

:) 

| align="center" |  <img src="smiles/happy.gif">

|-----

|

;) 

| align="center" |  <img src="smiles/eye.gif">

|-----

|

:D 

| align="center" |  <img src="smiles/haha.gif">

|-----

|

:( 

| align="center" |  <img src="smiles/sad.gif">

|-----

|

:p 

| align="center" |  <img src="smiles/toung.gif">

|-----

|

:[ 

| align="center" |  <img src="smiles/mad.gif">

|-----

|

:o 

| align="center" |  <img src="smiles/o.gif">

|-----

|

:] 

| align="center" |  <img src="smiles/ok.gif">

|-----

|

:thanx: 

| align="center" |  <img src="smiles/thank.gif">

|}

|-----

| border="1" | <br>

<center><a href="coment.php">::Back::</a></center><br>

|}</body>
De tot ce mai aveţi nevoie este o bază de date MySQL: chat.sql

-- 

-- Table structure for table `chat`

-- 


CREATE TABLE `chat` (

  `email` text NOT NULL,

  `nume` text NOT NULL,

  `mesaj` text NOT NULL,

  `ip` varchar(15) NOT NULL default '',

  `data` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Folosire

Acum nu aveţi dec??

Link to comment
Share on other sites

Este foarte bun tutorialul Acrono dar cred ca ai uitat sa ne dai o arhiva sau altceva cu folderul smiles.

Eu din codul :

$mesaj=str_replace(":)",'<img src="smiles/happy.gif">',$mesaj);

Inteleg ca atunci cand scriu : ) in chat sa imi apara un emoticon zambitor ca asta: :)

Lipseste folderul smiles,din cate se vede

Vezi poate mai este ceva de pus,IN REST TUTORIAL DE NOTA 10 ;)

Pc-helps-Toate intrebarile tale din IT au un raspuns,raspunsul il gasesti la noi!
Link to comment
Share on other sites

Ideal ar fi sa iti faci tu un folder in care sa pui imaginile, pentru ca nu este un singur set de smiley-uri. Fiecare prefera anumite smiley-uri, si cred ca nu este o munca prea mare sa iei un set de pe net. :)

edit: Shout box-ul este un fel de chat. Cred ca aici se foloseste un asemenea shout box: www.phpfusion.ro cauti in dreapta putin mai jos :)

Link to comment
Share on other sites

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.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.