mysql - php form submit isnt inserting into the database -


right, should basic php, cannot life of me figure out why not working.

i have form when submit should grab fields insert data database. have on index.php section pulls info database , works fine cant see being connection problem.

db_connection.php have hashed out info here database, correct

<?php define("db_server","**********"); define("db_user","*************"); define("db_pass","*********"); define("db_name","reviews");  $connection = mysqli_connect(db_server,db_user,db_pass,db_name);  if(mysqli_connect_errno()){     die("database connection failed"); }   ?> 

functions.php

<?php function redirect_to($new_location) {       header("location: " . $new_location);       exit;     }     function confirm_query($result){     if(!$result){         die("database query failed");     } } function find_reviews($connection){     $query  = "select * ";     $query .= "from reviews";     $result = mysqli_query($connection,$query);     confirm_query($result);     while($reviews = mysqli_fetch_assoc($result)){         $output = "<li class=\"first\">";         $output .= $reviews["name"];         $output .= "</li>";         $output .= "<li class=\"second\">";         $output .= $reviews["company"];         $output .= "</li>";         $output .= "<li class=\"third\">";         $output .= $reviews["comment"];         $output .= "</li>";         $output .= "<li class=\"line\"></li>";              echo $output;     }     mysqli_free_result($result);      return $reviews; } ?> 

index.php note this, function find_reviews() works , grab information database. above "db_connection.php" , "functions.php" required in index.php

<?php require("includes/header.php"); $page_title = "all county road markings"; $description = "specialising in road marking & car park lining. professional established road marking service on 20 years experience";?> <?php require("includes/db_connection.php"); ?> <?php require("includes/functions.php"); ?>  <?php if(isset($_post["submit"])){     $name = $_post["name"];     $company = $_post["company"];     $comment = $_post["comment"];     $query = "insert `reviews` (name,company,comment) values ('$name','$company','$comment')";      $result=mysqli_query($connection,$query);     confirm_query($result);     redirect_to("index.php"); } ?> <div id="banner"></div> <div id="paragraph">     <h2>all county road markings professional established road marking<br>service on 20 years experience within industry</h2>     <hr style="width: 1050px;"> </div> <div id="content">     <div id="left">         <div class="slot">             <div class="top carpark"> </div>             <div class="linkbar">                 <h1>car parks</h1>             </div><div class="linktext">                 <ul class="comments display">                     <li>- car parking bays</li>                     <li>- disabled parking bays</li>                     <li>- parent , child bays</li>                     <li>- lettering</li>                     <li>- hatchings</li>                     <li>- arrows</li>                     <li>- customised lettering</li>                 </ul>             </div>         </div>         <div class="slot">             <div class="top roadmark"> </div>             <div class="linkbar">                 <h1>road markings</h1>             </div>             <div class="linktext">                 <ul class="comments display">                     <li>- hatchings</li>                     <li>- centre lines</li>                     <li>- double yellow lines</li>                     <li>- give way junctions</li>                     <li>- reinstatement of existing markings</li>                 </ul>             </div>         </div>         <div class="slot">             <div class="top sportcourt">             </div>             <div class="linkbar">                 <h1>sports/playground court</h1>             </div>             <div class="linktext">                 <ul class="comments display">                     <li>- tennis court</li>                     <li>- basketball court</li>                     <li>- 5 side court</li>                     <li>- netball court </li>                     <li>- reinstatement of existing markings</li>                     <li>- custom designs available</li>                 </ul>             </div>         </div>     </div>     <div id="right">         <div id="rightbar">             <h2 style="color: white;">testimonials</h2>         </div>         <div id="comment">             <ul class="comments">                 <?php echo find_reviews($connection); ?>             </ul>         </div>         <div id="write">             <p style="margin: 0px; padding-top: 5px;color: grey; font-size: 1.25em;">click write review...<p>         </div>     </div>     <a href="contact.php"><div id="quote"><div class="link-text">contact us</div></div></a> </div> <div id="add">     <div id="close"></div>     <form action="index.php" method="post">         <div id="name"> name:<br/><span>please enter full name</span>             <input type="text" name="name" id="textbox">         </div>         <div id="company"> company<br/><span>please enter company name</span>             <input type="text" name="company" id="textbox1">         </div>         <div id="review"> review<br/><span>please enter review</span>             <textarea name="comment" id="reviewcomment"></textarea>         </div>         <div id="save">             <input type="submit" name="submit">         </div>     </form> </div> </body> </html> 

ok can see doing wrong? when form submitted not inserting database.

edit::

when try echo mysqli->error; following error:

 parse error: syntax error, unexpected t_object_operator, expecting ',' or ';' in /hermes/bosoraweb140/b484/ipg.allcountyroadmarking/index.php on line 17  

so changed

if(!results){      echo "hello"; } 

and not see "hello" indicating not getting part deals post fields

self resolved:::::

ive fixed it, changed action="index.php" action=""

i dont understand, should have worked , reason having action blank worked. both should acceptable !

the if statement $_post['submint'] might false on every submit. maybe try !empty($_post)


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -