Hello Everyone ,i just want to ask one question about the php condition statement
i insert comment by using the sql statement and i check the condition using like this
PHP Code:
if(isset($_POST['submit'])){
}
and i check the validation of form value if form is empty it don't work and
all field is complete ,the query is true
My problem is when i insert the comment and i reload the browser the query is return insert and everytime i reload this page my mysql query statement is working but i want to just one query when i click the submit button
How to solve this problem?
My Code is
PHP Code:
<?php
if(isset($_POST['submit']) ){
$name=$_POST['name'];
$email=$_POST['email'];
$comment=$_POST['comment'];
$comment_length=strlen($comment);
$limitcomment = 200;
if($comment_length > $limitcomment){
echo ' <script type="text/javascript">alert("Your message more than Limit !. \n Thanks for your Comment ");</script> ';
}else{
if((!empty($name))){ if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comment'])) { echo ' <script type="text/javascript">alert("Your Comment Success!. \n Please wait Admin Approval ");</script> ';
$comment_sql=mysql_query("INSERT INTO `tw_gallery`.`comment`
(`id`,`pho_id`,`name`,`email`,`comment`,`date`,`show`) VALUES (NULL,'$photoid','$name','$email','$comment',NOW(),'No')");
if($comment_sql){
echo ' <script type="text/javascript">alert("Your Comment Success!. \n Please wait Admin Approval ");</script> '; }else{ echo '<font color="red">Not Insert Comment</font>';
}
}
}else{
echo ' <script type="text/javascript">alert("Please enter the all field!. \n Thanks ");</script> ';
}
}
}
?>
<form action="" id="comment_form" method="post">
<label for="name">Name (Required)</label>
<input type="text" name="name" id="name" />
<label for="email">Email (Required)</label>
<input type="email" name="email" id="email" />
<label for="comment">Comment (Required)</label>
<textarea name="comment" id="comment" cols="30" rows="10"></textarea>
<input type="submit" name="submit" id="submit" value="Submit" />
</form>