php comment box help

Apr 6, 2009
30
2
0
යාලුවනේ මම php වලින් comment box එකක් හැදුවා එත් සිංහල පෙන්න මේ විදිහට .

English නම් අවුලක් නැතුව පෙනවා.. අනේ මට කවුරැ හරි කියලා දෙන්න කෝ........
commentprobpng.png


ඔන්න code එක..

HTML:
<div class="" style="margin-left:40px; margin-top:40px; margin-right:40px;">
                <?php
$username = "lanka_com";
$password = "147147";
$hostname = "localhost";
$con=mysql_connect($hostname,$username,$password) ;
$select = mysql_select_db("lanka_comment", $con);
$result = mysql_query("select id,name,comment FROM comment");
while ($row = mysql_fetch_array($result)) {

?>
                <div class='commentfullbox'>
                  <div class='commentnametype'>
                    <?php
echo "".$row['name'];
?>
                  </div>
                  <div class='commentname2'>
                    <?php
echo "".$row['comment'];
?>
                  </div>
                </div>
                <br />
                <br />
                <?php
}
?>
              </div>
 

Dead Island

Member
Mar 22, 2012
5,350
682
0
ඉතුරු ඒවාත් දාන්න. මතක ඇතුව php file එක save කරනකොට NOTEPAD එකෙන් UTF8 විදියට save කරන්න
 

Dead Island

Member
Mar 22, 2012
5,350
682
0
Code:
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
    <table border="0">
        <tr>
            <td>
            <div id="showthecomment">
            </div>
            </td>
        </tr>
        
        <tr>
            <td>
            <b>Commenter Name</b>
            </td>
            <td>
            <input type="text" name="typecommentname" style="width:346px"></input>
            </td>
        </tr>
        
        <tr>
            <td>
            <b>Comment<b>
            </td>
            <td>
            <textarea name="typecomment" cols="40" rows="20"></textarea>
            </td>
        </tr>
        <tr>
            <td>
            <input type="submit" name="submit">

            </input>
            </td>
        </tr>
    </table>
</form>


<?php

if(isset($_POST['submit']))//to submit the comments 
{

    $con = mysql_connect("localhost","root","");
        if(!$con)
        {
            die("error connecting to thedatabase" . mysql_error());
        }
    mysql_set_charset("utf8",$con);
    mysql_select_db("commentdb",$con);
    $queryString = "INSERT INTO comment (name,comment) VALUES('$_POST[typecommentname]','$_POST[typecomment]')";
    
    [B][COLOR=Red]mysql_query("SET NAMES utf8");[/COLOR][/B]
    if(!mysql_query($queryString,$con))
    {
    die('error posting the comment'.mysql_error());
    }

    echo "Comment was posted";
}


?>


ඊට පස්සේ
v82SH.png