Wahoo92583 Posted February 23, 2007 Share Posted February 23, 2007 How do I insert data into an access database via php? Link to comment https://forums.phpfreaks.com/topic/39833-access-database/ Share on other sites More sharing options...
Barand Posted February 23, 2007 Share Posted February 23, 2007 Set up and ODBC DSN to link the the access db (must be on same server as your web server) Use PHP's ODBC functions http://www.php.net/manual/en/ref.uodbc.php Link to comment https://forums.phpfreaks.com/topic/39833-access-database/#findComment-192443 Share on other sites More sharing options...
Wahoo92583 Posted February 24, 2007 Author Share Posted February 24, 2007 I am new to php and still am having a hard time understanding how to insert data into a access database via php using forms, may you please help? Link to comment https://forums.phpfreaks.com/topic/39833-access-database/#findComment-192756 Share on other sites More sharing options...
Barand Posted February 24, 2007 Share Posted February 24, 2007 see http://www.phpfreaks.com/tutorials/61/0.php Link to comment https://forums.phpfreaks.com/topic/39833-access-database/#findComment-192842 Share on other sites More sharing options...
Wahoo92583 Posted February 25, 2007 Author Share Posted February 25, 2007 I was not able to find anything that relates to php and forms along with databases Link to comment https://forums.phpfreaks.com/topic/39833-access-database/#findComment-193296 Share on other sites More sharing options...
Barand Posted February 25, 2007 Share Posted February 25, 2007 The code below has the basics for inserting into an Access db. You would need to add data validation and data sanitizing. Sample Table customers ====================== cust_id (auto_number) first_name last_name email <?php /** * check if data submitted */ if (isset($_POST[action])) { /** * get the form data */ $fn = $_POST['fn']; $ln = $_POST['ln']; $em = $_POST['em']; /** * connect to database via ODBC DSN */ $cnx = odbc_connect('DSN_NAME','',''); // use your odbc dsn name (must be system dsn) /** * insert data in table */ $sql = "INSERT INTO customers(first_name, last_name, email) VALUES ('$fn', '$ln', '$em')"; odbc_exec($cnx, $sql); } ?> <form method='post'> First name <input type="text" name="fn"><br> Last name <input type="text" name="ln"><br> Email <input type="text" name="em"><br> <input type="submit" name="action" value="Add new"> </form> Link to comment https://forums.phpfreaks.com/topic/39833-access-database/#findComment-193538 Share on other sites More sharing options...
Wahoo92583 Posted February 26, 2007 Author Share Posted February 26, 2007 I must not be doing something correctly because it will not work Link to comment https://forums.phpfreaks.com/topic/39833-access-database/#findComment-194001 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.