php/sql – Insert Data into Table with PHP (Bootstrap Form, if that makes a difference)

Bottom line: I don’t know what the hell I’m doing. I just want this comment box to submit information to my database. Let me show you what I got.

<form method="POST" action="post.php" style="font-
<label for="comments">Comments:</label>
<textarea class="form-control" placeholder="How can I improve?" 
 name="comments" rows="5" id="comments" value=""></textarea> <br>
<button type="submit" class="btn btn-default">Share Your Ideas</button>

and then my php i guess????

$servername = "localhost";
$username = "id1403626_wp_4764008ac42f7398450c24184e47c38a";
$password = "Marshall2";
$dbname = "id1403626_wp_257ecd760342ffcefce424435ed4e776";
//Collect Value of Input Field
$name = $_POST['comments'];
$timestamp = date('Y-m-d H:i:sa');

//Create connection
$connect = mysqli_connect($servername, $username, $password);

//Check connection
if ($connect->connect_error) {
die("So here's the problem...:".$connect->connect_error);
//Select Database
or die("Whoops! Can't find that pesky database!");
//Insert Data Query
$sql = "INSERT INTO `Comments`(`comments`, `date`) VALUES ($name, 
//What should happen
$result = mysqli_query($connect, $sql);

echo 'thank you for your feed back';
}else {
echo "Fuck man I can't code this shit right. If you have a comment email 
it to me at I'ma get this shit working one of 
these days.";

I just cannot find what I am doing wrong. Help a sista out, please!

Source: stackoverflow-php

Strange bootstrap behavior with Chrome/Sierra

I’m under OSX Sierra, Chrome 57, Bootstrap 3.3.7, Font awesome 4.

The following :

<button type="button" class="btn btn-primary btn-md" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i> wait">Go</button>

And the Js part :

$('.btn').on("click", (evt) => {

Does not work correctly. But It works with Safari !?

Any idea or workaround ?

Source: stackoverflow-javascript

Displaying PHP success and fail messages with Ajax

What went wrong in this code? I ready many post here on this issue but can’t fix my error. I have the following.


It worked
It failed

PHP Code

            echo "Failed!";

            echo "Inserted";


success: function(data){
        $('#addData').modal('hide');//close the modal.
        if (data=="Failed") {
            //console.log(data); is showing message from PHP
        } else{data=="Inserted"};
            //console.log(data); is showing message from PHP

Problem: I would like to display the error in the page not in console. I want to inform the user. Why is it not working with $("#successMessage").show();?

PS: I am using Bootstrap. Also how can I show my messages using one(1) div="msg" tag?

Source: stackoverflow-php

jquery .show does not work

I have a left side navbar in bootstrap, when clicking on a menu I want to show a section with Can’t see why it doesn’t show up:

      <!DOCTYPE htwml PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
  <html xmlns="">
   <meta charset="utf-8">
      <link href=""
          rel="stylesheet" type="text/css" />

      <style media="screen">
      /* make sidebar nav vertical */
  @media (min-width: 768px) {
  .sidebar-nav .navbar .navbar-collapse {
    padding: 0;
    max-height: none;
  .sidebar-nav .navbar ul {
    float: none;
  .sidebar-nav .navbar ul:not {
    display: block;
  .sidebar-nav .navbar li {
    float: none;
    display: block;
  .sidebar-nav .navbar li a {
    padding-top: 12px;
    padding-bottom: 12px;

      <style media="screen">
        .hidden {
          display: none;



Dynamic content in Bootstrap modal and dynamic data in Ajax [Laravel]

I have some problems while coding in Laravel, in particular with passing data to a modal (bootstrap framework) and passing data to an Ajax post request.
I have an array of items with an ‘id’, a ‘name’ and a ‘content’, that are retrieved from database and passed to the view. Below are the controller code and the view:


namespace AppHttpControllers;

use IlluminateHttpRequest;

class SiteController extends Controller
    public function index(){
    $items = AppItems::all();

    return view('home', compact('items'));

View (index.blade.php)

@foreach ($items as $item)

{{ $item->name }}

</div> @endforeach

When I click on the ‘button’ Delete, it will shows a modal. Below the code:

Call modal if the condition is meet – PHP

Im trying to make the modal show in the condition is met but the problem is no modal is showing, can someone help me about this? The php code is below of the modal code.

here’s the php

                        $stud_no = $_POST["stud_no"];
                      $password = $_POST["pword"];
                        $name = mysqli_real_escape_string($con, $stud_no);
                        $password = mysqli_real_escape_string($con, $password);
                        $select_user="SELECT * FROM student_accounts WHERE stud_no ='$stud_no' AND password ='$password'";
                        $run_user = mysqli_query($con, $select_user);
                        $check_user = mysqli_num_rows($run_user);
                        if($check_user > 0){
                        $_SESSION['stud_no'] = $stud_no;
                            header('location: home.php');

                             echo '$("#myModal").modal()';



here’s the modal

How do I prevent the tab from changing

I am able to get into the function it calls the prevent and I return false but the tab still switches? Any ideas of what I am doing wrong?

<ul class="nav nav-tabs" id="templateActionTab">
       <li id="menuTemplateTab" class="active"><a data-toggle="tab" href="#templateTab">Template</a></li>
       <li id="menuAction"><a data-toggle="tab" href="#actionTab">Action</a></li>
       <li id="menuScheduler"><a data-toggle="tab" href="#schedulerTab">Scheduler</a></li>

$(document).on('', 'a[data-toggle="tab"]', function (event) {

  var isValidationValid = templateInstance.validateScreen();

    localStorage.setItem('activeTab', $('href'));
    return true;

    return false;



Source: stackoverflow-javascript