spookszr Posted December 8, 2009 Share Posted December 8, 2009 I am in desperate need of someone who can help integrate two simple PHP scripts, one is a formmailer and the other enables data from the form to be entered into a MySQL database. The SQL component is below, and needs to be integrated into the second script. I would be your debt if anyone can help. When I add the first set of code to the second, the script runs, but no data is entered into the DB. Logins, etc have been replaced with Xs. SQL: <?php //Connect To Database $hostname='X'; $username='X'; $password='X'; $dbname='X'; $usertable='X'; mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.'); mysql_select_db($dbname); mysql_query("INSERT INTO $usertable (ReqAENAM, ReqEmail, CustomerAccount, ProductSold) VALUES ('$_POST[field_0]'),'$_POST[field_1]'),'$_POST[field_2]'),'$_POST[field_3]')"); mysql_close; ?> Formmailer: <?php define( 'PAYPAL_ID' , 'X' ); // Put donation ID here to disable the copyright link define( 'PHPFMG_ID' , 'X' ); define( 'PHPFMG_TO' , 'X' ); define( 'PHPFMG_REDIRECT', '' ); define( 'PHPFMG_ROOT_DIR' , dirname(__FILE__) ); define( 'PHPFMG_SAVE_FILE' , PHPFMG_ROOT_DIR . '/form-data-log.php' ); // save submitted data to this file define( 'PHPFMG_EMAILS_LOGFILE' , PHPFMG_ROOT_DIR . '/email-traffics-log.php' ); // log email traffics to this file define( 'PHPFMG_ADMIN_URL' , 'admin.php' ); define( 'PHPFMG_SAVE_ATTACHMENTS' , 'Y' ); define( 'PHPFMG_SAVE_ATTACHMENTS_DIR' , PHPFMG_ROOT_DIR . '/uploaded/' ); // three options : empty - always mail file as attachment, 0 - always mail file as link, N - mail file as link if filesize larger than N Megabytes define( 'PHPFMG_FILE2LINK_SIZE' , '' ); define( 'PHPFMG_BLOCK_HARMFUL' , '' ); define( 'PHPFMG_HARMFUL_EXTS' , '.exe, .com, .bat, .js, .vb, .vbs, scr, .inf, .reg, .lnk, .pif, .ade, .adp, .app, .bas, .bat, .chm, .cmd, .cpl, .crt, .csh, .exe, .fxp, .hlp, .hta, .inf, .ins, .isp, .js, .jse, .ksh, .Lnk, .mda, .mdb, .mde, .mdt, .mdt, .mdw, .mdz, .msc, .msi, .msp, .mst, .ops, .pcd, .pif, .prf, .prg, .pst, .reg, .scf, .scr, .sct, .shb, .shs, .url, .vb, .vbe, .vbs, .wsc, .wsf, .wsh' ); define( 'PHPFMG_HARMFUL_EXTS_MSG' , 'File is potential harmful. Upload is not allowed.' ); define( 'PHPFMG_CC' , 'X' ); define( 'PHPFMG_BCC', '' ); define( 'PHPFMG_SUBJECT' , "X" ); define( 'PHPFMG_RETURN_SUBJECT' , "X" ); // auto response mail subject define( 'PHPFMG_CHARSET' , 'UTF-8' ); define( 'PHPFMG_MAIL_TYPE' , 'html' ); // send mail in html format or plain text. define( 'PHPFMG_ACTION' , 'mailandfile' ); // delivery method define( 'PHPFMG_NO_FROM_HEADER' , 'N' ); // don't make up From: header. define( 'PHPFMG_SENDMAIL_FROM' , 'X' ); // force sender's email define( 'PHPFMG_SMTP' , 'X' ); // send email via this SMTP server define( 'HOST_NAME',getEnv( 'SERVER_NAME' ) ); define( 'PHP_SELF', getEnv( 'SCRIPT_NAME' ) ); define( 'ERR_MISSING', '<div class="form_error_title">Please check the required fields</div>' ); define( 'ERR_EMAIL', ' (not a valid e-mail address)' ); define( 'ERR_CREDIT_CARD_NUMBER', 'Please check the credit card number : ' ); define( 'ERR_CREDIT_CARD_EXPIRED', 'Please check the credit card expiry date : ' ); define( 'ERR_SELECT_UPLOAD', 'Please select upload file : ' ); define( 'ERR_CAPTCHA', 'Security Code' ); define( 'PHPFMG_ANTI_HOTLINKING' , '' ); define( 'PHPFMG_REFERERS_ALLOW', "" ); // Referers - domains/ips that you will allow forms to reside on. define( 'PHPFMG_REFERERS_DENIED_MSG', "You are coming from an <b>unauthorized domain.</b>" ); # ----------------------------------------------------------------------------- set_magic_quotes_runtime(0); error_reporting( E_ERROR ); session_start(); phpfmg_check_referers(); # ----------------------------------------------------------------------------- function phpfmg_auto_response_message(){ ob_start(); ?> %NameOfSender%, %DataOfForm% Sincerely, <?php $msg = ob_get_contents() ; ob_end_clean(); return trim($msg); } function phpfmg_mail_template(){ ob_start(); ?> %DataOfForm% Date: %Date% Time: %Time% <?php $msg = ob_get_contents() ; ob_end_clean(); return trim($msg); } # --- Array of Form Elements --- $form_mail['field_0'] = array( "name" => "field_0", "text" => "Requesting AE / NAM", "type" => "sender's name", "instruction" => "", "required" => "Required" ) ; $form_mail['field_1'] = array( "name" => "field_1", "text" => "Requestor\'s Email Address", "type" => "sender's email", "instruction" => "", "required" => "Required" ) ; $form_mail['field_2'] = array( "name" => "field_2", "text" => "Customer Account Name", "type" => "text", "instruction" => "", "required" => "Required" ) ; $form_mail['field_3'] = array( "name" => "field_3", "text" => "Products Sold", "type" => "checkbox", "instruction" => "", "required" => "Required" ) ; $form_mail['field_4'] = array( "name" => "field_4", "text" => "Number of Locations", "type" => "text", "instruction" => "", "required" => "Required" ) ; $form_mail['field_5'] = array( "name" => "field_5", "text" => "NAO Representative", "type" => "text", "instruction" => "", "required" => "" ) ; $form_mail['field_6'] = array( "name" => "field_6", "text" => "SSS Assigned", "type" => "text", "instruction" => "", "required" => "" ) ; $form_mail['field_7'] = array( "name" => "field_7", "text" => "Contract Signed", "type" => "select", "instruction" => "", "required" => "Required" ) ; $form_mail['field_8'] = array( "name" => "field_8", "text" => "MRR", "type" => "text", "instruction" => "", "required" => "Required" ) ; $form_mail['field_9'] = array( "name" => "field_9", "text" => "Term", "type" => "text", "instruction" => "", "required" => "Required" ) ; $form_mail['field_10'] = array( "name" => "field_10", "text" => "Service Level", "type" => "select", "instruction" => "", "required" => "Required" ) ; $form_mail['field_11'] = array( "name" => "field_11", "text" => "Estimated Project Start Date", "type" => "date(mm-dd-yyyy)", "instruction" => "", "required" => "" ) ; $form_mail['field_12'] = array( "name" => "field_12", "text" => "Estimated Project Complete Date", "type" => "date(mm-dd-yyyy)", "instruction" => "", "required" => "" ) ; $form_mail['field_13'] = array( "name" => "field_13", "text" => "Inside Plant Construction", "type" => "select", "instruction" => "", "required" => "Required" ) ; $form_mail['field_14'] = array( "name" => "field_14", "text" => "Outside Plant Construction", "type" => "select", "instruction" => "", "required" => "Required" ) ; $form_mail['field_15'] = array( "name" => "field_15", "text" => "Comments", "type" => "textarea", "instruction" => "", "required" => "" ) ; $form_mail['field_16'] = array( "name" => "field_16", "text" => "Please Attach All Drawings", "type" => "attachment", "instruction" => "", "required" => "" ) ; $form_mail['field_17'] = array( "name" => "field_17", "text" => "Please Attach All Drawings", "type" => "attachment", "instruction" => "", "required" => "" ) ; $form_mail['field_18'] = array( "name" => "field_18", "text" => "Please Attach All Drawings", "type" => "attachment", "instruction" => "", "required" => "" ) ; $form_mail['field_19'] = array( "name" => "field_19", "text" => "Please Attach All Drawings", "type" => "attachment", "instruction" => "", "required" => "" ) ; // -- Create new vars for checkPass() & sendFormMail() -- $field_3 = array(); $field_3[0]=$_POST[ "Checkbox01_field_3"]; $field_3[1]=$_POST[ "Checkbox02_field_3"]; $field_3[2]=$_POST[ "Checkbox03_field_3"]; $field_3[3]=$_POST[ "Checkbox04_field_3"]; $field_3[4]=$_POST[ "Checkbox05_field_3"]; $field_3[5]=$_POST[ "Checkbox06_field_3"]; $field_3[6]=$_POST[ "Checkbox07_field_3"]; $field_3[7]=$_POST[ "Checkbox08_field_3"]; $field_3[8]=$_POST[ "Checkbox09_field_3"]; $field_3[9]=$_POST[ "Checkbox10_field_3"]; $_POST[ "field_3" ] = join( "\n", $field_3); $_POST[ "field_11" ] = ( $_POST[ "field_11_YYYY" ] && $_POST[ "field_11_MM" ] && $_POST[ "field_11_DD" ] ) ? $_POST[ "field_11_YYYY" ] . "-" . $_POST[ "field_11_MM" ] . "-" . $_POST[ "field_11_DD" ] : "" ; $_POST[ "field_12" ] = ( $_POST[ "field_12_YYYY" ] && $_POST[ "field_12_MM" ] && $_POST[ "field_12_DD" ] ) ? $_POST[ "field_12_YYYY" ] . "-" . $_POST[ "field_12_MM" ] . "-" . $_POST[ "field_12_DD" ] : "" ; ?> <?php /** Continued... Quote Link to comment https://forums.phpfreaks.com/topic/184338-desperate-help-with-simple-php/ Share on other sites More sharing options...
RussellReal Posted December 8, 2009 Share Posted December 8, 2009 You're not gonna get many answers here if you don't use code tags on large codes.. but I'll advise you to rebuild both into 1 instead of simply trying to copy and paste the two together Quote Link to comment https://forums.phpfreaks.com/topic/184338-desperate-help-with-simple-php/#findComment-973197 Share on other sites More sharing options...
oni-kun Posted December 8, 2009 Share Posted December 8, 2009 Do you mean you wish to add the formmailer variables (such as paypal_id) to database? Or simply add the code together? Add the Database (and any session components) to the top, and check for any variables that are interfering. BUT. You can do something even simpler and just include it. Formmailer.php: <?php include 'database.php'; //your first file //Then rest of your code here, you can pull data from database or insert into.. Quote Link to comment https://forums.phpfreaks.com/topic/184338-desperate-help-with-simple-php/#findComment-973202 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.