user1680558
user1680558

Reputation: 23

Nothing will insert into my database

Here is the code: contact_us2.php

   <form id="form1" method="post" action="enquires.php">
 <fieldset>
 <legend>Form to database example</legend>
  <label for="text">
      <span>Comments:</span>
    <textarea id="text" name="comments" rows="4" cols="80"></textarea>
      </label>
      <label for="name">
     <span>Name:</span>
      <input id="name" type='text' name='name' size='50'/>
       </label>
      <label for="email">
    <span>Email:</span>
  <input id="email" type='text' name='email' size='50'/>
      </label>

     <label for="submit1" id="submit"><span>&nbsp;</span>
      <input id="submit1" class="submit" type="submit" name="submit" value="Submit"/>
      </label>
     </fieldset>
    </form>


                 enquires.php

                <?php
        session_start();
        error_reporting(E_ALL & ~E_NOTICE);
        require('authenticate.php');
        include_once"../scripts/connect_to_mysql.php";
        $name  = $_post['name'];
        $email = $_post['email'];
        $comments = $_post['comments'];
        echo "$email";
        // Query the body section for the proper page
        mysql_select_db("hardware_cms" )or die (mysql_error());
        $sqlCommand = MYSQL_QUERY("INSERT INTO enquires (id, name, email,      comments)". "VALUES ('NULL', '$name', '$email', '$comments')") or die (mysql_error()); 
        ?>

There is no errors. The only thing that is inserted into the database is the id. I think the problem is in contact_us2.php. I'm new to html and php sorry if this is a silly question.

Upvotes: 2

Views: 96

Answers (2)

wroniasty
wroniasty

Reputation: 8072

Replace $_post with $_POST and see what happens.

Also, PLEASE sanitize your SQL inputs (either by using mysql_real_escape_string, or better - by using PDO prepared statements).

Upvotes: 1

Alessandro Minoccheri
Alessandro Minoccheri

Reputation: 35973

The error is in the php code because you have to use $_POST and don't $_post

 $name  = $_POST['name'];
 $email = $_POST['email'];
 $comments = $_POST['comments'];

Upvotes: 2

Related Questions