Hello, im new to php want to know if any of you guy can help me with this problem. Im trying to add data to the database through a form. Here is the code for the form.
Date
Event
Here is the code to process form
<?php if (isset($_POST['submit'])) { include('event.php'); $date = $_POST['date']; $event = $_POST['event']; $sqlinsert = "INSERT INTO church (date, event) VALUES ('$date', '$event')"; if (!mysqli_query($dbcon, $sqlinsert)) { die('error inserting new event'); $newrecord = "1 record added to the database"; } // end of me nested if statement } // end of the main if ?>The include with the db connection
<?php define('DB_NAME' , 'myjesus2_xxxx'); define('DB_USER' , 'myjesus2_xxxx'); define('DB_PASSWORD' , 'xxxxxxxx'); define('DB_HOST' , 'localhost'); $dbcon = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$dbcon) { die('error connecting to database'); } echo 'you have connected sucessfully'; ?>I created 3 tables in mysql, ID, which is primary and auto INCREMENT, then i added date using date for the type and nulled is checked, the third is event and its type is varchar and its also nulled.
but i keep getting “you have connected sucessfullyerror inserting new event”
i can figure out problem… help please!!!