Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Set A Comment system by my own php code
- <div class="container text-left">
- <div class="row">
- <div class="col-md-6">
- <?php
- $con = mysql_connect('localhost','root','');
- if(!$con){
- die('connection codivdn\'t be created'.mysql_error());
- }
- // create database
- if( mysql_query('CREATE DATABASE messagedata',$con) ){
- echo 'database has been created<br>';
- }
- else{
- // echo 'database couldn\'t be created OR Database Already Created<br>';
- }
- // create table
- mysql_select_db('messagedata',$con);
- $table = 'CREATE TABLE messageinfo
- (
- name varchar (50),
- email varchar (50),
- comment varchar (1800)
- )
- ';
- if(mysql_query($table,$con)){
- // echo 'Table Has Been Created<br>';
- }
- // Data Preview
- mysql_select_db("messagedata",$con);
- $output = mysql_query ("SELECT * FROM messageinfo");
- $image = get_template_directory_uri();
- while($row = mysql_fetch_array ($output))
- {
- echo "<div style='color:#000;border:1px solid red;margin-bottom:5px;padding:15px;border-left:15px solid #4CB848;border-right:15px solid #4CB848;background:url($image/images/bg4.jpg') scroll 0px 0px'>";
- echo '<div><p>'.'Name : '.$row['name'].'</p></div>';
- echo '<div><p>'.'Email : '.$row['email'].'</p></div>';
- echo '<div><p>'.'Comments : '.$row['comment'].'</p></div>';
- echo '</div>';
- }
- echo "</div>";
- if(isset($_REQUEST['st_submit'])){
- $st_name = $_REQUEST['st_name'];
- $st_email = $_REQUEST['st_email'];
- $st_msg = $_REQUEST['st_msg'];
- if( ($st_name == true) && ($st_email == true) && ($st_msg == true) ){
- mysql_select_db('messagedata',$con);
- if(mysql_query("INSERT INTO messageinfo (name,email,comment) VALUE ('$st_name','$st_email','$st_msg')")){
- echo 'Data has been included';
- }
- }
- else{
- echo '<span style="color:red">Fill Up All Form Correctly</span> ';
- }
- }
- echo '<form action="" method="post">
- <table>
- <tr>
- <td>Name:</td>
- <td><input type="text" name="st_name" placeholder="Name" /></td>
- </tr>
- <tr>
- <td>Email:</td>
- <td><input type="email" name="st_email" placeholder="Email" /></td>
- </tr>
- <tr>
- <td>Comments:</td>
- <td><textarea style="width:335px;height:150px" type="text" name="st_msg" placeholder="Comments"></textarea></td>
- </tr>
- <tr>
- <td></td>
- <td><input type="submit" name="st_submit" value="Submit" /></td>
- </tr>
- </table>
- </form>';
- mysql_close($con);
- ?>
- <style type="text/css">
- td h2{padding:0 15px;margin:5px 0;font-size:15px;}
- input,textarea{padding-left:5px;}
- </style>
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement