-4

Can someone please tell me how to fix this. I have the html form coded right with the php file coded for the insert to database. I need help because when i click on the submit button it doesn't do anything. I need it to submit the information to the database and reset itself for the new person to fill it out.

Html:

<html>
    <head>
        <title></title>

        <link rel="stylesheet" href="css/contact_form.css" />

    </head>
    <body>
        <div id="wrap">
        <div class="box1"><img src="img/prive-logo-cut.png"/></div>
        <div class="box2">
        <div id="mainform">


            <!-- Required div starts here -->
                <form id="form" action="insert.php" method="post">
                <h3>Contact Form</h3>

                                <hr/><br/>
                                <label>Name: <span>*</span></label>
                <br/>
                <input type="text" id="name" name="name" placeholder="Name"/><br/>
                <br/>
                <label>Email: <span>*</span></label>
                <br/>
                <input type="text" id="email" name="email" placeholder="Email"/><br/>
                <br/>
                <label>Contact No: <span>*</span></label>
                <br/>
                                <input type="text" id="contact" name="contact" placeholder="Ex.0002223333"/><br/>
                <br/>
                <label>Message:</label>
                <br/>               
                                <textarea id="message" name="message" placeholder="Message......."></textarea><br/>
                <br/>
                <input type="button" id="submit" value="Send Message"/>
                                <br/>
                </form>
    <br />

        </div>
</div>
 </div><!--end wrap-->
    </body>
</html>

PHP

<?php


$user = "xxxx"; 
$password = "xxxx"; 
$host = "xxxx"; 
$dbase = "xxxx"; 
$table = "xxxx"; 


$name= $_POST['name'];
$email= $_POST['email'];
$contact= $_POST['contact'];
$message= $_POST['message'];



$dbc= mysqli_connect($host,$user,$password, $dbase) 
or die("Unable to select database");


$query= "INSERT INTO $table  ". "VALUES ('$name', '$email', '$contact', '$message')";


mysqli_query ($dbc, $query)
or die ("Error querying database");


echo 'Your Contact has been added.<br/> Thanks for sharing you information with us. <br/>Sincerely, <br/> xxx' . '<br>';


mysqli_close($dbc);

?>

1 Answers1

1

Found the problem. Here was the issue

$query= "INSERT INTO $table  ". "VALUES ('$name', '$email', '$contact', '$message')";

The fix

$query= "INSERT INTO $table  ". "VALUES ('', '$name', '$email', '$contact', '$message')";