dflow Posted November 26, 2008 Share Posted November 26, 2008 this form inserts data into the database correctly for some reason the form fields are not saved into the defined variables ??? ??? only $ITAgency is saved and POSTED as a result the $to variable in the mail function is empty and is not sent to the recipient any ideas thanks <?php require_once('../../Connections/international.php'); ?> <?php mysql_query("SET NAMES 'utf8'")?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO tourist_agencies (AgencyName, AgencyContactName, AgencyEmail, AgencyPhone, AgencyMobile, AgencyFax, AgencyAddress, AgencyZipCode, AgencyURL) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['AgencyName'], "text"), GetSQLValueString($_POST['AgencyContactName'], "text"), GetSQLValueString($_POST['AgencyEmail'], "text"), GetSQLValueString($_POST['AgencyPhone'], "text"), GetSQLValueString($_POST['AgencyMobile'], "text"), GetSQLValueString($_POST['AgencyFax'], "text"), GetSQLValueString($_POST['AgencyAddress'], "text"), GetSQLValueString($_POST['AgencyZipCode'], "text"), GetSQLValueString($_POST['AgencyURL'], "text")); mysql_select_db($database_international, $international); $Result1 = mysql_query($insertSQL, $international) or die(mysql_error()); } mysql_select_db($database_international, $international); $query_RsTAgents = "SELECT * FROM tourist_agencies"; $RsTAgents = mysql_query($query_RsTAgents, $international) or die(mysql_error()); $row_RsTAgents = mysql_fetch_assoc($RsTAgents); $totalRows_RsTAgents = mysql_num_rows($RsTAgents); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ADD TOURIST AGENTS FORM</title> <script type="text/javascript"> <!-- function MM_validateForm() { //v4.0 if (document.getElementById){ var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } } //--> </script> </head> <body> <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td colspan="2" align="center" nowrap="nowrap"><input name="TAgencyID" type="hidden" id="TAgencyID" value="<?php echo $row_RsTAgents['TAgencyID']; ?>" /> ADD TOURIST AGENTS FORM</td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">AgencyName:</td> <td><input type="text" name="AgencyName" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">AgencyContactName:</td> <td><input type="text" name="AgencyContactName" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">AgencyEmail:</td> <td><input name="AgencyEmail" type="text" id="AgencyEmail" onblur="MM_validateForm('AgencyEmail','','RisEmail');return document.MM_returnValue" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">AgencyPhone:</td> <td><input type="text" name="AgencyPhone" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">AgencyMobile:</td> <td><input type="text" name="AgencyMobile" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">AgencyFax:</td> <td><input type="text" name="AgencyFax" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">AgencyAddress:</td> <td><input type="text" name="AgencyAddress" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">AgencyZipCode:</td> <td><input type="text" name="AgencyZipCode" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right">AgencyURL:</td> <td><input type="text" name="AgencyURL" value="" size="32" /></td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" onclick="MM_validateForm('AgencyEmail','','R');return document.MM_returnValue" value="Insert record" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form> <p> </p> </body> </html> <?php mysql_free_result($RsTAgents); ?> <?php // get the last auto incremented value $lastItemID = mysql_insert_id(); ?> <?php /* grabs the POST variables and puts them into variables that we can use */ $TAgencyID=$lastItemID; $AgencyName=$_POST['$AgencyName']; $AgencyContactName=$_POST['$AgencyContactName']; $AgencyEmail=$_POST['$AgencyEmail']; $AgencyPhone=$_POST['$AgencyPhone']; $AgencyMobile=$_POST['$AgencyMobile']; $AgencyFax=$_POST['$AgencyFax']; $AgencyAddress=$_POST['$AgencyAddress']; $AgencyZipCode=$_POST['$AgencyZipCode']; $AgencyURL=$_POST['$AgencyURL']; ?> <?php // multiple recipients $to = $_POST['$AgencyEmail']; // subject $subject = ""; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; // Additional headers $headers .= "CC: info@mysite.com"; // Mail it // message $message =' '; $email = $_REQUEST['AgencyEmail'] ; if (!isset($_REQUEST['AgencyEmail'])) { } elseif (empty($email)) { } else { $url_success = "http://mysite.com/backoffice/Manager_control_panel/details_tourist_agents.php"; echo("<meta http-equiv = refresh content=0;url=".$url_success.">"); mail($to, $subject, $message, $headers); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/134354-solved-for-some-reason-the-form-fields-are-not-saved-into-the-defined-variables/ Share on other sites More sharing options...
BloodyMind Posted November 26, 2008 Share Posted November 26, 2008 please highlight the code by using the insert code in the upper panel Quote Link to comment https://forums.phpfreaks.com/topic/134354-solved-for-some-reason-the-form-fields-are-not-saved-into-the-defined-variables/#findComment-699470 Share on other sites More sharing options...
dflow Posted November 26, 2008 Author Share Posted November 26, 2008 thx and sorry Quote Link to comment https://forums.phpfreaks.com/topic/134354-solved-for-some-reason-the-form-fields-are-not-saved-into-the-defined-variables/#findComment-699472 Share on other sites More sharing options...
trq Posted November 26, 2008 Share Posted November 26, 2008 $to = $_POST['$AgencyEmail']; Should be.... $to = $_POST['AgencyEmail']; Quote Link to comment https://forums.phpfreaks.com/topic/134354-solved-for-some-reason-the-form-fields-are-not-saved-into-the-defined-variables/#findComment-699494 Share on other sites More sharing options...
trq Posted November 26, 2008 Share Posted November 26, 2008 In fact, all these.... $AgencyName=$_POST['$AgencyName']; $AgencyContactName=$_POST['$AgencyContactName']; $AgencyEmail=$_POST['$AgencyEmail']; $AgencyPhone=$_POST['$AgencyPhone']; $AgencyMobile=$_POST['$AgencyMobile']; $AgencyFax=$_POST['$AgencyFax']; $AgencyAddress=$_POST['$AgencyAddress']; $AgencyZipCode=$_POST['$AgencyZipCode']; $AgencyURL=$_POST['$AgencyURL']; are wrong. Quote Link to comment https://forums.phpfreaks.com/topic/134354-solved-for-some-reason-the-form-fields-are-not-saved-into-the-defined-variables/#findComment-699495 Share on other sites More sharing options...
dflow Posted November 26, 2008 Author Share Posted November 26, 2008 of course i excelled and combined multiple strings!!!! and left the $ thanks a lot sometimes one becomes blind Quote Link to comment https://forums.phpfreaks.com/topic/134354-solved-for-some-reason-the-form-fields-are-not-saved-into-the-defined-variables/#findComment-699509 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.