Jump to content

[SOLVED] for some reason the form fields are not saved into the defined variables


Recommended Posts

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); 

  }
?>

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.

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.