دوستان من هم دنباله یه همچین چیزی هستم guestbook ها کمی با comment متفاوت هستند!! کسی می دونه سیستم comment رو چه جوری باید راه انداخت؟قبل از هر چیز اگر سوال تکراری میکنم منو ببخشید .
می خواستم زیر هر پست یک فرم برای فرستادن نظر بزارم که کاربران نظر بفرستند و همونجا قابل مشاهده باشه اما نمیدونم چطوری و از کجا باید شروع کنم چون از php هی چی نمی دونم .
لطفا راهنماییم کنید .
مرسی
<p><table border="0" class="comments">
<tr>
<td>
User Comments:<br><br>
</td></tr>
<tr>
<td>
<?php
require 'connect.php';
$tutnum = 1;
$query='SELECT * FROM comments';
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
$numb=0;
$rate=0;
while ($i < $num) {
$tut=mysql_result($result,$i,"tut");
if($tut == $tutnum)
{
$comment=mysql_result($result,$i,'comment');
$dt=mysql_result($result,$i,'date');
$name=mysql_result($result,$i,'name');
$web=mysql_result($result,$i,'website');
$rating=mysql_result($result,$i,'rating');
echo "<a href='$web'>$name</a><br>";
echo "Posted this on $dt:<br><br>";
echo "$comment<br><br>";
echo "Rating: $rating<hr width='100%'><br>";
++$numb;
$rate = $rate + $rating;
}
++$i;
}
if($numb > 0)
{
$rate = $rate / $numb;
echo "Average user rating: $rate";
}
?>
</td>
</tr>
<tr><td>
<form action="../submit.php" method="post">
<input type="hidden" name="tutorial" value="<?=$tutnum?>"><br>
Name:<br> <input type="text" name="name"><br>
Website(type Mailto:youremail for email, and nothing for no website):<br><input type="text" name="web"><br>
How would you rate this tutorial(1-10, 10 being the best):<br> <input type="text" name="rating"><br>
Your Comment(s):<br> <textarea name="comments" rows="6" cols="100"></textarea><br>
<input type="Submit" value="Submit Comment">
</form>
</td></tr>
</table>
<br>
</p>
<?php
@mysql_connect("localhost", "root", "[password]") or die( "Unable to find MySQL");;
@mysql_select_db("[database]") or die( "Unable to select database");;
?>
<html><head>
</head>
<body>
<?php
require 'connect.php';
$_POST["comments"]=htmlspecialchars($_POST["comments"]);
$_POST["rating"]=htmlspecialchars($_POST["rating"]);
$_POST["name"]=htmlspecialchars($_POST["name"]);
$datetime = date("y-m-d H:i:s");
$tutorial = $_POST["tutorial"];
$comments = $_POST["comments"];
$web = $_POST["web"];
$rating = $_POST["rating"];
$name = $_POST["name"];
if($rating > 10|| $rating < 1)
{
die( "Please choose a rating between 1 and 10!");
}
if(!preg_match('/\S/',$name))
{
die( 'Please enter your name or screename!');
}
if(!preg_match('/\S/',$comments))
{
die( 'Don't spam us, enter some comments!!!!');
}
if(!preg_match('/\S/',$web))
{
$web == '#';
}
$query = "INSERT INTO comments VALUES ('$tutorial','$comments','$datetime','$web','$rating','$name')";
mysql_query($query);
echo 'Comment submitted sucessfully, please press the back button on your browser and refresh to view it.';
?>
</body>
</html>
در مورد اولی فکر نکنم چون یه دیتابیس ساختم و یوزر و پسورد و اسم دیتابیس رو قرار دادمًاشكال از فايل sql نيست چون اطلاعات داره و پره !
اشكال ممكنه از :
1 - فايل connect.php باشه كه تنظيم نكردي يا اشتباه تنظيم كردي
2 - مورد بعدي از فايل submit هست .
<?php
@mysql_connect("localhost", "samangos_comments", "123456") or die( "Unable to find MySQL");;
@mysql_select_db("samangos_comments") or die( "Unable to select database");;
?>
اره لطفا یکی کمک کنه !st4r-s4t گفت:به نظر من مشکل از submit هستش !! وقتی کامنت رو می فرستم به سابمیت که می رسه صفحه سفید می مونه!:
http://www.samangostar.org/submit.php
مشکل از کجاست یه php کار بیاد و کار ما رو راه بندازه!! ثواب داره بخدا!
<p><table border="0" class="comments">
<tr>
<td>
User Comments:<br><br>
</td></tr>
<tr>
<td>
<?php
require 'connect.php';
$tutnum = 1;
$query='SELECT * FROM comments';
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
$numb=0;
$rate=0;
while ($i < $num) {
$tut=mysql_result($result,$i,"tut");
if($tut == $tutnum)
{
$comment=mysql_result($result,$i,'comment');
$dt=mysql_result($result,$i,'date');
$name=mysql_result($result,$i,'name');
$web=mysql_result($result,$i,'website');
$rating=mysql_result($result,$i,'rating');
echo "<a href='$web'>$name</a><br>";
echo "Posted this on $dt:<br><br>";
echo "$comment<br><br>";
echo "Rating: $rating<hr width='100%'><br>";
++$numb;
$rate = $rate + $rating;
}
++$i;
}
if($numb > 0)
{
$rate = $rate / $numb;
echo "Average user rating: $rate";
}
?>
</td>
</tr>
<tr><td>
<form action="submit.php" method="post">
<input type="hidden" name="tutorial" value="<?=$tutnum?>"><br>
Name:<br> <input type="text" name="name"><br>
Website(type Mailto:youremail for email, and nothing for no website):<br><input type="text" name="web"><br>
How would you rate this tutorial(1-10, 10 being the best):<br> <input type="text" name="rating"><br>
Your Comment(s):<br> <textarea name="comments" rows="6" cols="100"></textarea><br>
<input type="Submit" value="Submit Comment">
</form>
</td></tr>
</table>
<br>
</p>
رفیق جون تست کردم!! مشکل داشت به صفحه submit.php میره ولی سفید می مونه!!يادداشتن نميخواد . كدي كه دادم رو جايگزين كدهاي فايل comment.php كنيد . اينقدر تنبل نباشيد . !
کی میگه کارنمی کنه!! کار می کنه توپ!آقا اينم فايل درست شده !
خودم n بار تست كردم . حضرت عباسي ديگه نگين كار نميكنه كه
يا علي
من عذر می خوام!راستي اينجا انجمن Php هست نه Perl دوست من !