farnoise Posted December 9, 2009 Share Posted December 9, 2009 Hi, I have a form with bunch of fields, Action is to send those fields to email address and send another copy to my MYSQL DB and store them, Everything was fine was fine until I switched my DB to ODBC and now my PHP code doesnt work, Well it works but it just send an email but no data goes to my DB, My DB code is Ok When I tried to send data to DB without mail() function everything was OK! But it wont work when I combine it. Anyway I'm looking for a way to send my form Values to 2 different PHP file 1 sends email and the otherone do my DB stuff! Any help!????? Quote Link to comment https://forums.phpfreaks.com/topic/184536-multiple-actions-on-form-action-php/ Share on other sites More sharing options...
premiso Posted December 9, 2009 Share Posted December 9, 2009 Post some code. It is hard for us to help based on 3 sentences of a description. An attempt to help, look into sessions for sending the data to the second PHP script and see if that helps. Quote Link to comment https://forums.phpfreaks.com/topic/184536-multiple-actions-on-form-action-php/#findComment-974209 Share on other sites More sharing options...
farnoise Posted December 9, 2009 Author Share Posted December 9, 2009 <?PHP Mail() function script goes here No problem with that PS: ALL VALUES HAS BEEN DEFINED HERE like: $date = check_input($_POST['date'], "Enter Start date"); $sn = check_input($_POST['sn'], "Please copy the Serial Number into the field"); $building = check_input($_POST['building'], "Choose the proper building"); ....... ?> /* ODBC STARTS HERE*/ <?php // connect to ODBC if ( !( $database = odbc_connect( "itdb", "",""))) die( "Could not connect to database" ); /* run insert */ $stmt = odbc_prepare($database, "INSERT INTO newhires (dates, lastname, firstname, initial, location, wwwaccess, rules, folders, manager, email, managerinfo, list, sn) VALUES('$_POST[date]', '$_POST[lastname]', '$_POST[firstname]', '$_POST[initial]', '$_POST[location]', '$_POST[wwwaccess]', '$_POST[rules]', '$_POST[folders]', '$_POST[manager]', '$_POST', '$_POST[managerinfo]', '$list', $_POST[sn])"); /* check for errors */ if (!odbc_execute( $stmt)) { /* error */ echo "Whoops"; } ?> /*END HERE*/ <HTML> Some HTML code goes here to show error messages to user </HTML> <?php exit(); } ?> I thought about season but I dont know how to use it can you give me an example please! Quote Link to comment https://forums.phpfreaks.com/topic/184536-multiple-actions-on-form-action-php/#findComment-974218 Share on other sites More sharing options...
premiso Posted December 9, 2009 Share Posted December 9, 2009 For an example / explanation of Session read the tutorial: Sessions and cookies: Adding state to a stateless protocol And for future code postings, please post them within // your code here tags Quote Link to comment https://forums.phpfreaks.com/topic/184536-multiple-actions-on-form-action-php/#findComment-974233 Share on other sites More sharing options...
farnoise Posted December 9, 2009 Author Share Posted December 9, 2009 By the way I played with it for a while and I found my answer works perfectly fine here is the code: /*OPEN */ if ( !( $database = odbc_connect( "itdb", "",""))) die( "Could not connect to database" ); $stmt = odbc_prepare($database, "INSERT INTO newhires (dates, lastname, firstname, initial, location, wwwaccess, rules, folders, manager, email, managerinfo, list, sn) VALUES('$_POST[date]', '$_POST[lastname]', '$_POST[firstname]', '$_POST[initial]', '$_POST[location]', '$_POST[wwwaccess]', '$_POST[rules]', '$_POST[folders]', '$_POST[manager]', '$_POST[email]', '$_POST[managerinfo]', '$list', $_POST[sn])"); /* check for errors */ if (!odbc_execute( $stmt)) { /* error */ echo "Whoops"; } /*CLOSE */ I just removed <?PHP tage and used the body script of ODBC connection inside of my mail() function, Quote Link to comment https://forums.phpfreaks.com/topic/184536-multiple-actions-on-form-action-php/#findComment-974244 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.