Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Keep your damn code clean, so you can understand what you are cooking... This will work for you:</p> <pre><code>$(document).ready(function(){ $("#comment_form").submit(function(e){ e.preventDefault(); // stop refresh var name = $("#name").val(); var email = $("#email").val(); var comment_area = $("#comment_area").val(); var dataString = 'name='+ name + '&amp;email=' + email + '&amp;comment_area=' + comment_area+'&amp;submit_comment=true'; var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; var emailaddressVal = $("#email").val(); if(name=='' || !emailReg.test(emailaddressVal) || comment==''){ alert('Please enter valid data and type in message'); } else{ $.ajax({ type: "POST", url: "comments.php", data: dataString, cache: false, success: function(html){ $("#com_list").append(html); $("#com_list").fadeIn("slow"); $("#flash").fadeOut('fast'); } }); } }); $('#cancel').click(function(e){ e.preventDefault(); $('.slider').hide(); $('#com_list').show(); }); }); </code></pre> <p>Here is some more clean code...</p> <pre><code>&lt;div class="slider"&gt; &lt;form id="comment_form" name="comment_form" method="post" action="#" enctype="multipart/form-data"&gt; &lt;input type="text" id="name" name="name" maxlength="16"/&gt;&amp;nbsp;Name&lt;br /&gt;&lt;br/&gt; &lt;input type="text" id="email" name="email"/&gt;&amp;nbsp;Email&amp;nbsp;(will not show)&lt;br /&gt;&lt;br/&gt; &lt;textarea id="comment_area" name="comment_area" maxlength="1000"&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br/&gt; &lt;input type="submit" class="submit" name="submit_comment" value="submit"/&gt;&amp;nbsp;&amp;nbsp;comment or &lt;a href="index.php" id="cancel"&gt;&lt;u&gt;cancel&lt;/u&gt;&lt;/a&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>Here is some other clean and <strong>SECURE</strong> code</p> <pre><code>&lt;?php if(isset($_POST['submit_comment'])){ $name = mysql_real_escape_string($_POST['name']); $email = mysql_real_escape_string($_POST['email']); $comment_area = mysql_real_escape_string($_POST['comment_area']); //$lowercase = strtolower($email); //$image = md5( $lowercase ); $query = 'INSERT INTO comments (name,email,comment,com_date) '. "VALUES ('$name','$email','$comment_area',CURDATE())"; $insert = mysqli_query($connect, $query); } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload