Skip to main content
se añadieron 9 caracteres en el cuerpo; título editado
Origen Enlace

Recibir un aviso cuando alguinalguien deje un comentario en mi web

Tengo este código, que es un formulario para dejar comentarios en mi web. Me gustaría saber si hay alguna manera de conseguir que añadiendo algo más de código pueda llegarme un aviso a mi correo cuando alguien deje un comentario en la web. El código que os dejo funciona bien, no tiene fallos solo lo pongo para que veáis lo que estoy utilizando.Gracias por adelantado

         <div class="container">
   <form method="POST" id="comment_form">
<div class="form-group">
 <input type="text" name="comment_name" id="comment_name" class="form- 
  control" placeholder="Enter Name" />
</div>
<div class="form-group">
 <textarea name="comment_content" id="comment_content" class="form-control" 
  placeholder="Enter Comment" rows="5"></textarea>
</div>
<div class="form-group">
 <input type="hidden" name="comment_id" id="comment_id" value="0" />
 <input type="submit" name="submit" id="submit" class="btn btn-info" 
   value="Submit" />
</div>

 add_comment.php:



  <?php

//add_comment.php


  $connect = new PDO('mysql:host=);

   $error = '';
   $comment_name = '';
   $comment_content = '';

      if(empty($_POST["comment_name"]))
     {
     $error .= '<p class="text-danger">Name is required</p>';
    }
      else
    {
     $comment_name = $_POST["comment_name"];
      }

    if(empty($_POST["comment_content"]))
   {
    $error .= '<p class="text-danger">Comment is required</p>';
    }
    else
    {
     $comment_content = $_POST["comment_content"];
     }

     if($error == '')
    {
    $query = "
   INSERT INTO tbl_comment 
 (parent_comment_id, comment, comment_sender_name) 
 VALUES (:parent_comment_id, :comment, :comment_sender_name)
  ";
 $statement = $connect->prepare($query);
 $statement->execute(
  array(
   ':parent_comment_id' => $_POST["comment_id"],
   ':comment'    => $comment_content,
   ':comment_sender_name' => $comment_name
     )
    );
     $error = '<label class="text-success">Comment Added</label>';
     }

     $data = array(
 'error'  => $error
    );

echo json_encode($data);

?>

aviso cuando alguin deje comentario en mi web

         <div class="container">
   <form method="POST" id="comment_form">
<div class="form-group">
 <input type="text" name="comment_name" id="comment_name" class="form- 
  control" placeholder="Enter Name" />
</div>
<div class="form-group">
 <textarea name="comment_content" id="comment_content" class="form-control" 
  placeholder="Enter Comment" rows="5"></textarea>
</div>
<div class="form-group">
 <input type="hidden" name="comment_id" id="comment_id" value="0" />
 <input type="submit" name="submit" id="submit" class="btn btn-info" 
   value="Submit" />
</div>

 add_comment.php

  <?php

//add_comment.php


  $connect = new PDO('mysql:host=);

   $error = '';
   $comment_name = '';
   $comment_content = '';

      if(empty($_POST["comment_name"]))
     {
     $error .= '<p class="text-danger">Name is required</p>';
    }
      else
    {
     $comment_name = $_POST["comment_name"];
      }

    if(empty($_POST["comment_content"]))
   {
    $error .= '<p class="text-danger">Comment is required</p>';
    }
    else
    {
     $comment_content = $_POST["comment_content"];
     }

     if($error == '')
    {
    $query = "
   INSERT INTO tbl_comment 
 (parent_comment_id, comment, comment_sender_name) 
 VALUES (:parent_comment_id, :comment, :comment_sender_name)
  ";
 $statement = $connect->prepare($query);
 $statement->execute(
  array(
   ':parent_comment_id' => $_POST["comment_id"],
   ':comment'    => $comment_content,
   ':comment_sender_name' => $comment_name
     )
    );
     $error = '<label class="text-success">Comment Added</label>';
     }

     $data = array(
 'error'  => $error
    );

echo json_encode($data);

?>

Recibir un aviso cuando alguien deje un comentario en mi web

Tengo este código, que es un formulario para dejar comentarios en mi web. Me gustaría saber si hay alguna manera de conseguir que añadiendo algo más de código pueda llegarme un aviso a mi correo cuando alguien deje un comentario en la web. El código que os dejo funciona bien, no tiene fallos solo lo pongo para que veáis lo que estoy utilizando.Gracias por adelantado

       <div class="container">
   <form method="POST" id="comment_form">
<div class="form-group">
 <input type="text" name="comment_name" id="comment_name" class="form- 
  control" placeholder="Enter Name" />
</div>
<div class="form-group">
 <textarea name="comment_content" id="comment_content" class="form-control" 
  placeholder="Enter Comment" rows="5"></textarea>
</div>
<div class="form-group">
 <input type="hidden" name="comment_id" id="comment_id" value="0" />
 <input type="submit" name="submit" id="submit" class="btn btn-info" 
   value="Submit" />
</div>

 add_comment.php:



  <?php

//add_comment.php


  $connect = new PDO('mysql:host=);

   $error = '';
   $comment_name = '';
   $comment_content = '';

      if(empty($_POST["comment_name"]))
     {
     $error .= '<p class="text-danger">Name is required</p>';
    }
      else
    {
     $comment_name = $_POST["comment_name"];
      }

    if(empty($_POST["comment_content"]))
   {
    $error .= '<p class="text-danger">Comment is required</p>';
    }
    else
    {
     $comment_content = $_POST["comment_content"];
     }

     if($error == '')
    {
    $query = "
   INSERT INTO tbl_comment 
 (parent_comment_id, comment, comment_sender_name) 
 VALUES (:parent_comment_id, :comment, :comment_sender_name)
  ";
 $statement = $connect->prepare($query);
 $statement->execute(
  array(
   ':parent_comment_id' => $_POST["comment_id"],
   ':comment'    => $comment_content,
   ':comment_sender_name' => $comment_name
     )
    );
     $error = '<label class="text-success">Comment Added</label>';
     }

     $data = array(
 'error'  => $error
    );

echo json_encode($data);

?>
Origen Enlace

aviso cuando alguin deje comentario en mi web

         <div class="container">
   <form method="POST" id="comment_form">
<div class="form-group">
 <input type="text" name="comment_name" id="comment_name" class="form- 
  control" placeholder="Enter Name" />
</div>
<div class="form-group">
 <textarea name="comment_content" id="comment_content" class="form-control" 
  placeholder="Enter Comment" rows="5"></textarea>
</div>
<div class="form-group">
 <input type="hidden" name="comment_id" id="comment_id" value="0" />
 <input type="submit" name="submit" id="submit" class="btn btn-info" 
   value="Submit" />
</div>

 add_comment.php

  <?php

//add_comment.php


  $connect = new PDO('mysql:host=);

   $error = '';
   $comment_name = '';
   $comment_content = '';

      if(empty($_POST["comment_name"]))
     {
     $error .= '<p class="text-danger">Name is required</p>';
    }
      else
    {
     $comment_name = $_POST["comment_name"];
      }

    if(empty($_POST["comment_content"]))
   {
    $error .= '<p class="text-danger">Comment is required</p>';
    }
    else
    {
     $comment_content = $_POST["comment_content"];
     }

     if($error == '')
    {
    $query = "
   INSERT INTO tbl_comment 
 (parent_comment_id, comment, comment_sender_name) 
 VALUES (:parent_comment_id, :comment, :comment_sender_name)
  ";
 $statement = $connect->prepare($query);
 $statement->execute(
  array(
   ':parent_comment_id' => $_POST["comment_id"],
   ':comment'    => $comment_content,
   ':comment_sender_name' => $comment_name
     )
    );
     $error = '<label class="text-success">Comment Added</label>';
     }

     $data = array(
 'error'  => $error
    );

echo json_encode($data);

?>