Jump to content

Recommended Posts

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!?????  :confused:

Link to comment
https://forums.phpfreaks.com/topic/184536-multiple-actions-on-form-action-php/
Share on other sites

<?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!

 

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,

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.