$n = $_FILES['image']['name'];
            move_uploaded_file($t, $upload . $n);
            //upload file to directory
            //save form data in Database
            Comments_form::save_data($user_name, $user_comment, $email, $comment_date, $phone);
            //start send email
            $to = $email;
            $subject = 'Hello,your comments';
            $message = 'Comment date ' . $comment_date . "\r\n";
            $message .= 'Phone ' . $phone . "\r\n";
            $message .= 'Comment ' . $user_comment . "\r\n";
            $headers = "Content-type: text/html; charset=windows-1251 \r\n";
            $headers .= "From: Birthday Reminder bogdandvinin@example.com \r\n";
            mail($to, $subject, $message, $headers);
            //send email
            //end send email
        } else {
            exit;
            //if file size > 0.5m exit
        }
    } else {
        //if user don't upload file - we save other data to Database
        //save form data to Database
        $query = Comments_form::save_data($user_name, $user_comment, $email, $comment_date, $phone);
        if ($query == TRUE) {
            // if needed, we can provide information to the user (but in our case JavaScript reports)
        } else {
            $_SESSION['info'] = 'Error to add comment';
        }
    }
}
Example #2
0
                        <th>
                            <p id="user_data">Comment</p>
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <p id="user_comment_show"></p>
                        </td>
                    </tr>
                </table>
            </div>
    </div>
    <!-----------------------------END Block to show added comments by JavaScript -->
    <!--$all_comment variable to show all user comments -->
    <?php 
$all_comments = Comments_form::select_all();
?>
    <?php 
if (mysqli_num_rows($all_comments) > 0) {
    ?>
    <hr class="line">
    <!--Start .panel .panel-primaty to show all user comments -->
    <!--Show all user comment from Database -->
    <div  style="margin-top: 33px"  class="panel panel-primary">
        <?php 
    while ($res = mysqli_fetch_assoc($all_comments)) {
        ?>
            <div style="background-color: #cccccc" class="panel-body">
                <h4 style="text-align: center" ><?php 
        echo $res['user_name'];
        ?>