Form sometimes submitting data, sometimes not. Magento 1.9 - php

I have a page where I call a form, receiving reports from users that sometimes it just doesn't submit properly. Not sure why. Any ideas?
Users have been reporting this in various browsers, so it's been especially difficult to track down. Chrome, IE, Edge, Safari, etc. have all reported it, but sometimes it just works.
What the form is supposed to do is take the entered data, then email it to a specific email address.
Magento Block:
<div class="page-title">
<h1>Program</h1>
</div>
<img class="textwrap-right" src="{{media url="wysiwyg/cfi_rebate_badge.png"}}" alt="" />
<div class="std">
<h3 class="ui-helper-clearfix">Sign up below.</h3>
{{widget type="mailform/widget_form" form_template="contacts/cfi.phtml"}}<br />
</div>
This is my contacts/cfi.phtml template:
<?php
$directory = Mage::helper('directory');
$customer = Mage::getSingleton('customer/session')->getCustomer();
$customerAddress = $customer->getAddressById( $customer->getDefaultBilling() );
if($customerAddress->getCountryId() != 'US'){
$customerAddress = Mage::getModel('customer/address');
}
?>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<form action="<?php echo $this->getFormAction() ?>" id="contactForm" method="post" class="scaffold-form">
<div class="fieldset">
<h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
<p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
<ul class="form-list">
<li class="fields">
<div class="field">
<label for="cfirebate:name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label>
<div class="input-box">
<input name="cfirebate[name]" id="cfirebate:name" title="<?php echo Mage::helper('contacts')->__('Name') ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
</div>
</div>
<input type="hidden" name="cfirebate[country]" id="cfirebate:country_id" value="US">
<div class="field">
<label for="cfirebate:address" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Address') ?></label>
<div class="input-box">
<input name="cfirebate[address]" id="cfirebate:address" title="<?php echo Mage::helper('contacts')->__('Address') ?>" class="input-text required-entry" type="text" />
</div>
</div>
<div class="field">
<label for="cfirebate:city" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('City') ?></label>
<div class="input-box">
<input name="cfirebate[city]" id="cfirebate:city" title="<?php echo Mage::helper('contacts')->__('City') ?>" class="input-text required-entry" type="text" />
</div>
</div>
<div class="field">
<div class="field">
<label for="cfirebate:region" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="cfirebate:region_id" name="cfirebate[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
<option value="">Please select region, state or province</option>
</select>
</div>
</div>
</div>
<div class="field">
<label for="cfirebate:postcode" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Zip') ?></label>
<div class="input-box">
<input name="cfirebate[postcode]" id="cfirebate:postcode" title="<?php echo Mage::helper('contacts')->__('Zip') ?>" class="input-text required-entry" type="text" />
</div>
</div>
<div class="field">
<label for="cfirebate:email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label>
<div class="input-box">
<input name="cfirebate[email]" id="cfirebate:email" title="<?php echo Mage::helper('contacts')->__('Email') ?>" class="input-text required-entry validate-email" type="email" autocapitalize="off" autocorrect="off" spellcheck="false" />
</div>
</div>
</li>
<li>
<label for="cfirebate:telephone"><?php echo Mage::helper('contacts')->__('Phone Number') ?></label>
<div class="input-box">
<input name="cfirebate[telephone]" id="cfirebate:telephone" title="<?php echo Mage::helper('contacts')->__('Phone Number') ?>" class="input-text" type="tel" />
</div>
</li>
<li class="wide">
<label for="cfirebate:comment"><?php echo Mage::helper('contacts')->__('Comment') ?></label>
<div class="input-box">
<textarea name="cfirebate[comment]" id="cfirebate:comment" title="<?php echo Mage::helper('contacts')->__('Comment') ?>" class="input-text" cols="5" rows="3"></textarea>
</div>
</li>
</ul>
</div>
<div class="buttons-set">
<input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
<button type="submit" title="<?php echo Mage::helper('contacts')->__('Submit') ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var contactForm = new VarienForm('contactForm', true);
var cfiRegionUpdater = new RegionUpdater('cfirebate:country_id', 'cfirebate:region', 'cfirebate:region_id', <?php echo $directory->getRegionJson() ?>, undefined, 'cfirebate:postcode');
//]]>
</script>

Try adding form key inside the form:
<input type="hidden" name="form_key" value="<?php echo $this->getFormKey(); ?>">
Just add the above code anywhere inside your form markup.

Related

Stop PHP from auto generating values

I am new in php. I have a PHP script which auto generates a tracking number in mysql database cons_no is the name of the table, I wish to enter the cons_no data manually.
Also when I try to edit the cons_no value from the edit page, other things are allowed to be edited - except con_no. Any help will be appreciated.
This is the code that creates the the file with the cons_no value.
<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
session_start();
//Include database configuration file
require_once('database-settings.php');
require_once('database.php');
$db = conexion();
require_once('library.php');
require_once('funciones.php');
require 'requirelanguage.php';
include_once "filtro/class/class.php";;
include_once "filtro/class_buscar.php";
require_once("filtro/class/class.inputfilter.php");
$ifilter = new InputFilter();
$_POST = $ifilter->process($_POST);
$sql = "SELECT DISTINCT(off_name)
FROM offices";
$result = dbQuery($sql);
$company=mysql_fetch_array(mysql_query("SELECT * FROM company"));
date_default_timezone_set($_SESSION['ge_timezone']);
$fechai=date('Y-m-d');
$fechaf=date('Y-m-d');
isUser();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php echo $_SESSION['ge_cname']; ?> | <?php echo $ENVIOS; ?></title>
<meta name="description" content="<?php echo $_SESSION['ge_description']; ?>"/>
<meta name="keywords" content="<?php echo $_SESSION['ge_keywords']; ?>" />
<meta name="author" content="Jaomweb">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<link rel="shortcut icon" type="image/png" href="img/favicon.png"/>
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="../bower_components/animate.css/animate.css" type="text/css" />
<link rel="stylesheet" href="../bower_components/font-awesome/css/font-awesome.min.css" type="text/css" />
<link rel="stylesheet" href="../bower_components/simple-line-icons/css/simple-line-icons.css" type="text/css" />
<link rel="stylesheet" href="css/font.css" type="text/css" />
<link rel="stylesheet" href="css/app.css" type="text/css" />
<link href="css/style.css" rel="stylesheet" media="all">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600' rel='stylesheet' type='text/css'>
<!-- Switchery css -->
<link href="assets/plugins/switchery/switchery.min.css" rel="stylesheet" />
<!-- Plugins css -->
<link href="assets/plugins/timepicker/bootstrap-timepicker.min.css" rel="stylesheet">
<link href="assets/plugins/mjolnic-bootstrap-colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
<link href="assets/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet">
<link href="assets/plugins/clockpicker/bootstrap-clockpicker.min.css" rel="stylesheet">
<link href="assets/plugins/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
</head>
<body>
<?php
include("header.php");
?>
<!-- content -->
<div id="content" class="app-content" role="main">
<div class="app-content-body ">
<div class="wrapper-md">
<div class="row">
<div class="col-sm-12">
<div class="blog-post">
<div class="panel">
<div class="wrapper-lg">
<div>
<tbody>
<div class="row alertaCaja" style="display: none;">
<div class="col-xs-4 col-sm-4 col-md-4" style="float: none; margin: 0 auto;">
<div class="alert alert-dismissible alert danger">
<button type="button" class="close" data-dismiss="alert"><img src="img/close.png" height="15" width="15"></button>
<center>
<?php
require_once('database.php');
$query= mysql_query("SELECT MAX(cid) AS id FROM courier");
if ($row = mysql_fetch_row($query))
{
?>
<a target="_blank" href="print-invoice/invoice-print.php?cid=<?php echo codificar($id = trim($row[0])); ?>">
<img src="img/print-invoice.png" height="76" width="79"></a>
<?php } ?>
<?php
require_once('database.php');
$query= mysql_query("SELECT MAX(cid) AS id FROM courier");
if ($row = mysql_fetch_row($query))
{
?>
<a target="_blank" href="print-invoice/ticket-print.php?cid=<?php echo codificar($id = trim($row[0])); ?>">
<img src="img/print_label.png" height="76" width="79"></a>
<?php } ?>
</center>
</div>
</div>
</div>
<?php if ( isset ( $_GET ['tipo'] ) ) { ?>
<div class="row alertaCaja" style="display: none;" >
<div class="col-xs-6 col-sm-6 col-md-6" style="float: none; margin: 0 auto;">
<div class="alert alert-dismissible alert-<?php echo $_GET ['tipo'] ?>">
<button type="button" class="close" data-dismiss="alert">x</button>
<strong><?php echo $L_['message']; ?></strong><br/><br/> <?php echo $_GET ['mensaje']; ?>
</div>
</div>
</div>
<?php } ?>
<tr>
<h3 class="classic-title"><span><strong><i class="fa fa-truck icon text-default-lter"></i> <?php echo $ADICIONAR; ?></strong></h3>
<!-- START Checkout form -->
<form action="settings/add_courier/agregar.php" method="post" >
<table border="0" align="center" width="100%" >
<div class="row">
<!-- START Presonal information -->
<fieldset class="col-md-6">
<legend><?php echo $datosremite; ?></legend>
<!-- Name -->
<div class="row" >
<div class="col-sm-2 form-group">
<label class="control-label"><i class="fa fa-user icon text-default-lter"></i> <?php echo $StaffRole; ?><span class="required-field">*</span></label>
<input type="text" class="form-control" name="officename" id="officename" value="<?php echo $_SESSION['user_type'] ;?>" readonly="true" />
</div>
<div class="col-sm-2 form-group">
<label class="control-label"><i class="fa fa-user icon text-default-lter"></i> <?php echo $StaffUser; ?><span class="required-field">*</span></label>
<input type="text" class="form-control" name="user" id="user" value="<?php echo $_SESSION['user_name'] ;?>" readonly="true" />
</div>
<div class="col-sm-8 form-group">
<label class="control-label" ><?php echo $NOMBREREMITENTE; ?><span class="required-field">*</span></label>
<input type="text" class="form-control" name="Shippername" id="Shippername" autocomplete="on" list="customers" />
<datalist id="customers">
<?php
$sql=mysql_query("SELECT * FROM tbl_clients");
while($row=mysql_fetch_array($sql)){
echo '<option data-value="'.$row['id'].'">'.utf8_encode($row['name']).'</option>';
}
?>
</datalist>
<input type="hidden" name="Shippername-hidden" id="Shippername-hidden" />
</div>
</div>
<div class="row">
<div id="divRemi">
<div class="col-sm-6 form-group">
<label class="control-label"><?php echo $DIRECCION; ?><span class="required-field">*</span></label>
<input type="text" class="form-control" name="Shipperaddress" id="Shipperaddress" placeholder="<?php echo $placeremi; ?>" />
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><i class="fa fa-phone icon text-default-lter"></i> <?php echo $TELEFONO; ?></label>
<input type="tel" class="form-control" name="Shipperphone" id="Shipperphone" placeholder="<?php echo $placetele; ?>" />
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><?php echo $CEDULA; ?></i></label>
<input type="text" class="form-control" name="Shippercc" id="Shippercc" placeholder="<?php echo $placeced; ?>" >
</div>
<div class="col-sm-3 form-group" style="display:none">
<label class="control-label"><?php echo $L_['lockerid']; ?></i></label>
<input type="text" class="form-control" name="Shipperlocker" id="Shipperlocker" placeholder="<?php echo $L_['lockerid']; ?>">
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><i class="fa fa-angle-double-right icon text-default-lter"></i> <strong><?php echo $PAISORIGEN; ?></strong></label>
<input type="text" class="form-control" name="Pickuptime" id="Shippercountry" placeholder="<?php echo $L_['placecountry']; ?>">
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><strong><?php echo $L_STATE; ?></strong></label>
<input type="text" class="form-control" name="state" id="Shipperstate" placeholder="<?php echo $L_['placestate']; ?>">
</div>
<div class="col-sm-3 form-group" style="display:none">
<label class="control-label"><strong><?php echo $CODIGO; ?></strong></label>
<input type="text" class="form-control" name="iso" id="Shipperiso" placeholder="<?php echo $L_['placeiso']; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><strong><?php echo $CIUDAD; ?></strong></label>
<input type="text" class="form-control" id="Shipperciudad" name="ciudad" placeholder="<?php echo $L_['placecity']; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><strong><?php echo $CODIGOPOSTAL; ?></strong></label>
<input type="text" class="form-control" id="Shipperzipcode" name="zipcode" placeholder="<?php echo $codigopostal; ?>">
</div>
<div class="col-sm-12 form-group">
<p class="error"></p>
<label class="control-label"><?php echo $EMAIL; ?><font color="#FF6100"><?php echo $notaemail; ?></font></i></label>
<input type="email" class="form-control" name="Shipperemail" id="idemail" placeholder="demo#emo.com" autocomplete=" off" onKeyUp="javascript:validateeMail('idemail')" />
<strong><span id="mailOK"></span></strong>
<p class="error"></p>
</div>
</div>
</div>
<!-- Adress and Phone -->
<!-- START Shipment information -->
</br></br>
<legend><?php echo $Informaciondeenvio; ?></legend>
<div class="row">
<!-- Origin Office -->
<div class="col-sm-3 form-group">
<label for="zipcode" class="control-label"><i class="fa fa-angle-double-right icon text-default-lter"></i> <strong><?php echo $OFICINAORIGEN; ?></strong></label>
<select class="form-control" name="Invoiceno">
<?php
while($data = dbFetchAssoc($result)){
?>
<option value="<?php echo $data['off_name']; ?>"><?php echo $data['off_name']; ?></option>
<?php
}//while
?>
</select>
</div>
<div class="col-sm-3 form-group">
<label for="ccv" class="control-label"><strong><?php echo $CantidadPaquetes; ?></strong></i></label>
<input type="number" class="form-control" name="Qnty" placeholder="<?php echo $placecant; ?>" />
</div>
<!-- Text area -->
<div class="col-sm-6 form-group">
<label for="inputTextarea" class="control-label"><i class="fa fa-comments icon text-default-lter"></i> <?php echo $DetallesdelEnvio; ?></label>
<textarea class="form-control" name="Comments" placeholder="<?php echo $placedetails; ?>" ></textarea>
</div>
</div>
<div class="row">
<div class="col-sm-5 form-group">
<label class="control-label"><i class="fa fa-database icon text-default-lter"></i> <strong><?php echo $Pagos; ?></strong></label>
<select class="form-control" name="bookingmode">
<option selected="selected" value="Effective"><?php echo $Effective; ?></option>
<option value="Debit_card"><?php echo $Debitcard; ?></option>
<option value="Credit_card"><?php echo $Creditcard; ?></option>
<option value="Transfer"><?php echo $Transfer; ?></option>
<option value="Online"><?php echo $Payonline; ?></option>
<option value="Paypal"><?php echo $L_['type_paypal']; ?></option>
</select>
</div>
<div class="col-sm-4 form-group">
<label class="control-label"><?php echo $TipodeProducto; ?></label>
<select type="text" class="form-control" name="Shiptype" >
<?php
$sql="SELECT name FROM type_shipments GROUP BY name";
$query=$db->query($sql);
if($query->num_rows>0){
while($row=$query->fetch_array()){
echo '<option data-value="'.$row['name'].'">'.utf8_encode($row['name']).'</option>';
}
}
?>
</select>
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><i class="fa fa-plane icon text-default-lter"></i> <?php echo $MododelServicio; ?></label>
<select class="form-control" name="Mode">
<?php
$sql="SELECT name FROM mode_bookings GROUP BY name";
$query=$db->query($sql);
if($query->num_rows>0){
while($row=$query->fetch_array()){
echo '<option data-value="'.$row['name'].'">'.utf8_encode($row['name']).'</option>';
}
}
?>
</select>
</div>
</div>
<!-- Payment Mode -->
<div class="row">
<div class="col-sm-3 form-group" >
<label class="text-danger"><strong><?php echo $_SESSION['ge_curr']; ?> <?php echo $ValorDeclarado; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="suma();" id="sum2" name="Totaldeclarate" value="0" />
</div>
<div class="col-sm-3 form-group" >
<label class="text-danger"><strong><?php echo $Declarado; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="suma();" id="sum5" name="Totaldeclarado" value="4" />
</div>
<div class="col-sm-3 form-group">
<label for="ccv" class="text-danger"><strong><?php echo $_SESSION['ge_curr']; ?> <?php echo $ValorRecogida; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="suma();" id="sum3" name="Totalfreight" value="0" />
</div>
<div class="col-sm-3 form-group">
<label class="text-danger"><strong><?php echo $_SESSION['ge_curr']; ?> <?php echo $PrimerKilo; ?> <?php echo $_SESSION['ge_measure']; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="suma();" id="sum1" name="variable" value="3.25" />
</div>
<div class="col-sm-3 form-group">
<label class="text-danger"><strong><?php echo $_SESSION['ge_curr']; ?> <?php echo $_SESSION['ge_measure']; ?> <?php echo $KiloAdicional; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="suma();" id="sum6" name="kiloadicional" value="3.25" />
</div>
<div class="col-sm-3 form-group">
<label class="text-danger"><strong><?php echo $PesoKg; ?> (<?php echo $_SESSION['ge_measure']; ?>)<strong></label>
<input type="text" class="form-control" required onblur="if(this.value == ''){this.value='0'}" onKeyUp="suma();" id="sum4" name="Weight" value="0" />
</div>
<div class="col-sm-3 form-group">
<label class="text-danger"><strong><?php echo $SubtotalEnvio; ?><strong></i></label>
<input type="text" class="form-control" name="shipping_subtotal" id="resultado" value="0" />
</div>
<div class="col-sm-3 form-group">
<label class="text-danger"><strong><?php echo $_SESSION['ge_curr']; ?> <?php echo $PesoFisico; ?><strong></label>
<input type="text" class="form-control" id="pesoreal" name="pesoreal" onblur="if(this.value == ''){this.value='0'}" >
</div>
</div>
<legend><?php echo $pesovolumetrico; ?>:</legend>
<!-- Peso Volumetrico -->
<div class="row">
<div class="col-sm-3 form-group">
<label class="text-primary"><strong><?php echo $Altura; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="volumetrico();" id="volume1" name="altura" placeholder="<?php echo $Altura; ?>" />
</div>
<div class="col-sm-3 form-group">
<label class="text-primary"><strong><?php echo $Ancho; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="svolumetrico();" id="volume2" name="ancho" placeholder="<?php echo $Ancho; ?>" />
</div>
<div class="col-sm-3 form-group">
<label class="text-primary"><strong><?php echo $Longitud; ?><strong></label>
<input type="text" class="form-control" onblur="if(this.value == ''){this.value='0'}" onKeyUp="volumetrico();" id="volume3" name="longitud" placeholder="<?php echo $Longitud; ?>" />
</div>
<div class="col-sm-3 form-group">
<label class="text-primary"><strong><?php echo $TotalPesoVolumetrico; ?><strong></i></label>
<input type="text" class="form-control" name="totalpeso" id="totalpeso" placeholder="0,00" />
</div>
</div>
</fieldset>
<!-- START Receiver info -->
<fieldset class="col-md-6">
<legend><?php echo $DatosDestinatario; ?></legend>
<!-- Name -->
<div class="form-group">
<label class="control-label"><?php echo $NOMBREDESTINATARIO; ?><span class="required-field">*</span></label>
<input type="text" class="form-control" name="Receivername" id="Receivername" autocomplete="on" list="customers" >
</div>
<!-- Adress and Phone -->
<div class="row">
<div class="col-sm-3 form-group">
<label class="control-label"><?php echo $DIRECCION; ?><span class="required-field">*</span></label>
<input type="text" class="form-control" name="Receiveraddress" id="Receiveraddress" placeholder="<?php echo $placedirdesti; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><i class="fa fa-phone icon text-default-lter"></i> <?php echo $TELEFONO; ?></label>
<input type="tel" class="form-control" name="Receiverphone" id="Receiverphone" placeholder="<?php echo $placeteldesti; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><i class="fa fa-phone icon text-default-lter"></i> <?php echo $TELEFONO2; ?></label>
<input type="tel" class="form-control" name="telefono1" id="Receivertelefono1" placeholder="<?php echo $placeteldesti; ?>">
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><?php echo $CEDULA; ?></i></label>
<input type="text" class="form-control" name="Receivercc_r" id="Receivercc_r" placeholder="<?php echo $L_['placecedr']; ?>">
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><i class="fa fa-angle-double-right icon text-default-lter"></i> <strong><?php echo $PAISDESTINO; ?></strong></label>
<input type="text" class="form-control" name="paisdestino" id="Receivercountry1" placeholder="<?php echo $L_['placecountry1']; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><strong><?php echo $L_STATE; ?></strong></label>
<input type="text" class="form-control" name="state1" id="Receiverstate1" placeholder="<?php echo $L_['placestate']; ?>" >
</div>
<div class="col-sm-3 form-group" style="display:none">
<label class="control-label"><strong><?php echo $CODIGO; ?></strong></label>
<input type="text" class="form-control" name="iso1" id="Receiveriso1" placeholder="<?php echo $L_['placeiso']; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><strong><?php echo $CIUDAD; ?></strong></label>
<input type="text" class="form-control" name="city1" id="Receivercity1" placeholder="<?php echo $L_['placecity']; ?>" >
</div>
<div class="col-sm-3 form-group">
<label class="control-label"><strong><?php echo $CODIGOPOSTAL; ?></strong></label>
<input type="text" class="form-control" name="zipcode1" id="Receiverzipcode1" placeholder="<?php echo $codigopostal; ?>">
</div>
<div class="col-sm-12 form-group">
<p class="error"></p>
<label class="control-label"><?php echo $EMAIL; ?><font color="#FF6100"><?php echo $notaemail; ?></font></i></label>
<input type="email" class="form-control" name="Receiveremail" id="id_mail" placeholder="demo#emo.com" onKeyUp="javascript:validateMail('id_mail')" >
<strong><span id="emailOK"></span></strong>
<p class="error"></p>
</div>
</div>
</br></br>
<!-- Name -->
<div class="form-group">
<label for="name-card" class="text-success"><strong><?php echo $NUMEROENVIO; ?></strong></label>
<?php
$qryEmpresa = mysql_query("SELECT * FROM company");
while($row = mysql_fetch_array($qryEmpresa)) {
$pre = $row["prefijo"];
$cons = $row["cons_no"];
}
mysql_free_result($qryEmpresa);
$pa=mysql_query("SELECT MAX(cons_no)as maximo FROM c_tracking");
if($row=mysql_fetch_array($pa)){
if($row['maximo']==NULL){
$cons_no=''.$cons.'';
}else{
$cons_no=$row['maximo']+1;
}
}
?>
<input type="text" class="form-control" value="<?php echo $_SESSION['ge_prefix']; ?>-<?php echo "".$cons_no; ?>">
</div>
</br>
<!-- Status and Pickup Date -->
<div class="form-group">
<label for="dtp_input1" class="control-label"><i class="fa fa-calendar icon text-default-lter"></i> <?php echo $FECHARECOLECCIONENVIO; ?></i></label>
<div>
<div class="input-group">
<input type="text" class="form-control" name="Packupdate" placeholder="mm/dd/yyyy" id="datepicker-autoclose" >
<span class="input-group-addon bg-custom b-0"><i class="glyphicon glyphicon-calendar"></i></span>
</div><!-- input-group -->
</div>
</div>
<div class="row">
<div class="col-sm-4 form-group">
<label for="month" class="control-label"><i class="fa fa-sort-amount-asc icon text-default-lter"></i> <?php echo $estado; ?></label>
<select class="form-control" name="status" id="status">
<?php
$sql="SELECT servicemode FROM service_mode GROUP BY servicemode";
$query=$db->query($sql);
if($query->num_rows>0){
while($row=$query->fetch_array()){
echo '<option data-value="'.$row['servicemode'].'">'.utf8_encode($row['servicemode']).'</option>';
}
}
?>
</select>
</div>
<div class="col-sm-8 form-group">
<label for="dtp_input1" class="control-label"><i class="fa fa-calendar icon text-default-lter"></i> <?php echo $fechaestimadadeliver; ?></i></label>
<div>
<div class="input-group">
<input type="text" class="form-control" name="Schedule" placeholder="mm/dd/yyyy" id="datepicker">
<span class="input-group-addon bg-custom b-0"><i class="glyphicon glyphicon-calendar"></i></span>
</div><!-- input-group -->
</div>
</fieldset>
<div class="col-md-6 text-left">
</br></br>
<button type="submit" id="submit" class="btn btn-large btn-success"><?php echo $GUARDARENVIO; ?></button>
</div>
</div>
</div>
</div>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- / content -->
<?php include("footer.php"); ?>
<?php include("footer_add_courier.php"); ?>

Custom contact form: Unable to submit your request. Please, try again later

I created a new contact form in:
app/design/frontend/base/default/template/contacts
Named form2.phtml
I am getting the error: Unable to submit your request. Please, try again later.
Here's my code:
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div>
<h2>Questions? Comments?<br>
Contact us here and we’ll get back to you shortly.</h2>
<form action="<?php echo $this->getFormAction(); ?>" id="contactForm2" class="footer-form" method="post">
<div class="fieldset">
<ul class="form-list">
<div class="form-row">
<li>
<div class="input-box">
<input placeholder="First Name *" name="first name" id="name" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('First Name')) ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
</div>
</li>
<li>
<div class="input-box">
<input placeholder="Last Name *" name="last name" id="name" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Last Name')) ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
</div>
</li>
</div>
<div class="form-row">
<li>
<div class="input-box">
<input placeholder="Email *" name="email" id="email" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Email')) ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email" type="text" />
</div>
</li>
<li>
<div class="input-box">
<input placeholder="Telephone" name="telephone" id="telephone" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Telephone')) ?>" value="" class="input-text" type="text" />
</div>
</li>
</div>
<li class="wide">
<div class="input-box">
<textarea placeholder="Message *" name="comment" id="comment" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Comment')) ?>" class="required-entry input-text" cols="5" rows="3"></textarea>
</div>
</li>
</ul>
</div>
<div class="buttons-set">
<input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
<button type="submit" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Submit')) ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('SEND') ?></span></span></button>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var contactForm = new VarienForm('contactForm', true);
//]]>
</script>
Any ideas what would be causing this? The default form works fine when I switch it back to it. Did I miss a step somewhere?
Thanks
Since you have the "hideit" input added, commented out
if (Zend_Validate::is(trim($post[’hideit’]), ‘NotEmpty’)) {
$error = true;
}
inside app/code/core/Mage/contacts/controllers/indexController.php

How to add radio button and Test schedule with date and time?

I had created the form with some details but I added the radio button and it is not working for getting the values to print on my mail and I have tried to add the date and time using dropdown list but it is not working fine.
the radio buttons should be required.It has to show as in below image as alert for radio button and Test schedule but it is not getting as in the image
Please any one help me.It is very important for me.
My form
<form action="http://www.labwise.in/devel/zensearch/order" id="bookingtest" method="post">
<div class="fieldset">
<ul class="form-list">
<li class="fields">
<div class="field">
<label for="testname" class="required"><em>*</em><?php echo $this->__('Test Name') ?> </label>
<div class="input-box">
<input type="text" id="testname" name="testname" value="<?php echo $_GET['name']?>" class="input-text required-entry" title="<?php echo $this->__('Test Name') ?>" />
</div>
</div>
<div class="field">
<label for="city" class="required"><em>*</em><?php echo $this->__('City') ?> </label>
<div class="input-box">
<input type="text" id="city" name="city" value="<?php echo $_GET['city']?>" class="input-text required-entry" title="<?php echo $this->__('City') ?>" />
</div>
</div>
</li>
<li>
<label for="location" class="required"><em>*</em><?php echo $this->__('Location') ?> </label>
<div class="input-box">
<input type="text" id="location" name="location" value="<?php echo $_GET['location']?>" class="input-text required-entry" title="<?php echo $this->__('Location') ?>" />
</div>
</li>
<li class="fields">
<div class="field">
<label for="cname" class="required"><em>*</em><?php echo $this->__('Name') ?> </label>
<div class="input-box">
<input type="text" id="cname" name="cname" value="" class="input-text required-entry" title="<?php echo $this->__('Name') ?>" />
</div>
</div>
<div class="field">
<label for="email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
<div class="input-box">
<input type="text" name="email" value="<?php echo $this->escapeHtml($this->getUsername()) ?>" id="email" class="input-text required-entry validate-email" title="<?php echo $this->__('Email Address') ?>" />
</div>
</div>
</li>
<li>
<label for="mobile" class="required"><em>*</em><?php echo $this->__('Mobile Number') ?> </label>
<div class="input-box">
<input type="text" id="mobile" name="mobile" value="" class="input-text required-entry validate-mobileno" title="<?php echo $this->__('Mobile Number') ?>" />
</div>
</li>
<li>
<label class="required"><em>*</em><?php echo $this->__('Sample Collection') ?> </label></li>
<li>
<div class="radio_button">
<input type="radio" name="radio" class="input-text required-entry validate-select" value="I will visit Lab"> I will visit Lab
</div>
<div>
<input type="radio" name="radio" class="input-text required-entry validate-select" value="Visit me at home/office +Rs50.00" > Visit me at home/office +Rs50.00
</div>
</li>
<li>
<label for="requiredby" class="required"><em>*</em><?php echo $this->__('Test Schedule') ?> </label>
<div class="input-box">
<input type="text" id="requiredby" name="requiredby" value="" class="input-text required-entry" title="<?php echo $this->__('Test Schedule') ?>" style="width: 150px;" />
<img style="" title="Select Date" id="date_select_trig" alt="" src="<?php echo $this->getSkinUrl("images/calendar.gif");?> "/>
<select name="date_time" id="date_time" class="input-text required-entry validate-select" style="width: 50px;" />
<option value=""><?php echo $this->__('--')?></option>
<option value="1"><?php echo $this->__('1')?></option>
<option value="2"><?php echo $this->__('2')?></option>
<option value="3"><?php echo $this->__('3')?></option>
<option value="4"><?php echo $this->__('4')?></option>
<option value="5"><?php echo $this->__('5')?></option>
<option value="6"><?php echo $this->__('6')?></option>
<option value="7"><?php echo $this->__('7')?></option>
<option value="8"><?php echo $this->__('8')?></option>
<option value="9"><?php echo $this->__('9')?></option>
<option value="10"><?php echo $this->__('10')?></option>
<option value="11"><?php echo $this->__('11')?></option>
<option value="12"><?php echo $this->__('12')?></option>
</select>
<b>:</b>
</div>
</li>
</ul>
</div>
<div class="button">
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
<button id= "submit" type="submit" class="button" title="<?php echo $this->__('Book Test') ?>" name="send" id="send2"><span><span><?php echo $this->__('Book Test') ?></span></span></button>
</div>
</form>
<script src="<?php echo Mage::getBaseUrl('js')."calendar/calendar.js" ?>" type="text/javascript"></script>
<script src="<?php echo Mage::getBaseUrl('js')."calendar/calendar-setup.js" ?>" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<?php echo Mage::getBaseUrl('js') ?>calendar/calendar-win2k-1.css" />
<?php echo $this->getLayout()->createBlock('core/html_calendar')->setTemplate('page/js/calendar.phtml')->toHtml();?>
<script type="text/javascript">
if(Validation) {
Validation.addAllThese([
['validate-mobileno','Enter correct mobile number (Eg:9986858483)',
function(v){
//var timePat ="^((\+){0,1}91(\s){0,1}(\-){0,1}(\s){0,1}){0,1}9[0-9](\s){0,1}(\-){0,1}(\s){0,1}[1-9]{1}[0-9]{7}$";
var timePat ="^{0,1}9[0-9](\s){0,1}(\-){0,1}(\s){0,1}[1-9]{1}[0-9]{7}$";
// var matchArray = v.match(timePat);
if(v.length > 0){
if(v.length !=10){
return false;
}else if(v[0]!=9 && v[0]!=8 && v[0]!=7){
return false;
}
return true;
}else {
return false;
}
}
]])
};
var dataForm = new VarienForm('bookingtest', true);
</script>
<script type="text/javascript">
// <![CDATA[
Calendar.setup({
inputField : 'testschedule',
ifFormat : '%d-%b-%Y',
showsTime: false,
button : 'date_select_trig',
singleClick : true,
});
// ]]>
</script>
This is one way of getting rid of that deep level of nesting.
var visit = document.getElementById('visit-required');
var form = document.forms.bookingtest;
form.addEventListener('submit', function(e){
if(!form.lab.checked && form.office.checked){
e.preventDefault();
visit.style.display = 'block';
}
});
.marked-required{
color: #FF0000;
}
.message-required{
display: none;
color: #FF0000;
}
#options{
border: 2px solid #FF0000;
}
#datetime > input{
display: inline-block;
vertical-align: top;
}
Place this php in the file you want to post to.
/* example.php */
<?php
print_r($_POST);
?>
<form action="example.php" id="bookingtest" method="post">
<strong>Sample collection <span class='marked-required'>*</span></strong>
<div id='options'>
<input type='radio' name='visit' id='lab'/>I will visit Lab<br/>
<input type='radio' name='visit' id='office'/>Visit me at home/office + Rs50.00
</div>
<small class='message-required' id='visit-required'>Please select one of the option.</small>
<br/>
<strong>Test schedule<span class='marked-required'>*</span></strong>
<div id='datetime'>
<input type='text' />
<select>
<option>From</option>
</select>
<select>
<option>To</option>
</select>
<select>
<option>AM</option>
<option>PM</option>
</select>
<small class='message-required'>This is a required option</small>
</div>
<input type='submit' id='submit' value='Submit'/>
</form>

Undefined index: template_id

I am karthik, in my project i have one problem, i am getting error undefine index: template_id. I have searched more in net but i can't rectify this problem i have attached my code below, please guide me
if($fetquery["template_id"] == 5){
$query = mysql_query("SELECT * FROM ".$fetquery['table_name']." WHERE template_content_id = ".$fetquery['id']."");
$fetquery = mysql_fetch_array($query);
?>
<!-- Template5-->
<input type="hidden" name="template5" value="template5">
<div class="fillContent" id="subscreen5">
<div class="mainTitle">
<h3>Fill Content - Template E</h3>
</div>
<input type="hidden" name="template5id" value="<?php echo $fetquery['temp5_id']; ?>">
<div class="current-title">
<label>Main Title</label> <input type="text" class="fillTitleText" name="etemp5title"placeholder="Lorem Ipsum" value="<?php echo $fetquery['title']; ?>"><!-- Edit -->
</div>
<div class="section2">
<div class="contentSecTitle">
<h3>Banner Image</h3>
</div>
<div class="subSec">
<div class="subSec1">
<div class="contentSec2Left">
<input type="text" id="template5banner" value="<?php echo $fetquery['bannerimage']; ?>" class="upLoadText">
<div class="fileUpload btn btn-primary">
<span class="uploadImage"></span>
<input id="temp5_bannerimg" onchange="addtemplate5banner(this)" name="etemplate5bannerimg" type="file" class="upload" value="Browse">
</div>
</div>
<div class="contentSecRight">
<input type="hidden" name="gettopImage" value="<?php echo $fetquery['bannerimage']; ?>">
<p class="imageView3"><img src="<?php echo $fetquery['bannerimage']; ?>" style="width:82px; height:82px;" id="changetemp5banner"><br><br>Current Image</p>
<!-- <p class="imageView4">filename.jpg</p>
<div class="deLete">
</div>
-->
</div>
</div>
</div>
</div>
<div class="fillSec">
<div class="contentSecTitle">
<h3>Content</h3>
</div>
<div class="current-textarea">
<div class="text-area">
<label>Description</label> <textarea rows="4" name="etemp5desc" ><?php echo $fetquery['description']; ?></textarea>
</div>
</div>
</div>
</div>
<?php
}
if($fetquery["template_id"] == 6){
//echo "SELECT * FROM ".$fetquery['table_name']." WHERE template_content_id = ".$fetquery['id']."";
$query = mysql_query("SELECT * FROM ".$fetquery['table_name']." WHERE template_content_id = ".$fetquery['id']."");
$fetquery = mysql_fetch_array($query);
?>
<!-- Template6-->
<input type="hidden" name="template6" value="template6">
<div class="fillContent" id="subscreen6">
<div class="mainTitle">
<h3>Fill Content - Template F</h3>
</div>
<input type="hidden" name="template6id" value="<?php echo $fetquery['temp6_id']; ?>">
<div class="current-title">
<label>Main Title</label> <input value="<?php echo $fetquery['title']; ?>" type="text" class="fillTitleText" name="etemplate6title" placeholder="Lorem Ipsum"> <!--Edit -->
</div>
<div class="section2">
<div class="contentSecTitle">
<h3>Banner Image</h3>
</div>
<div class="subSec">
<div class="subSec1">
<div class="contentSec2Left">
<input type="text" id="template6banner" value="<?php echo $fetquery['bannerimage']; ?>" class="upLoadText">
<div class="fileUpload btn btn-primary">
<span class="uploadImage"></span>
<input id="temp6_bannerimg" onchange="addtemplate6banner(this)" name="template6bannerimg" type="file" class="upload" value="Browse">
</div>
</div>
<div class="contentSecRight">
<input type="hidden" name="gettopImage" value="<?php echo $fetquery['bannerimage']; ?>">
<p class="imageView3"><img src="<?php echo $fetquery['bannerimage']; ?>" style="width:82px; height:82px;" id="changetemp6banner"><br><br>Current Image</p>
<!-- <p class="imageView4">filename.jpg</p>
<div class="deLete">
</div> -->
</div>
</div>
</div>
</div>
<div class="fillSec">
<div class="contentSecTitle">
<h3>Content</h3>
</div>
<div class="current-textarea">
<div class="text-area">
<label>Desription</label> <textarea rows="4" name="temp6desc"><?php echo $fetquery['description']; ?></textarea>
</div>
</div>
</div>
</div>
<?php } ?>
This code was in ajax page
Try to add a check before using it. And also check if it is defined or not. -
if (!empty($fetquery["template_id"]) && $fetquery["template_id"] == 5) { ...

Reset button using JavaScript is not working after validating the form using Ajax

I have a "create user"form with reset and create button. This reset button is not working for some drop-downs in the form.
In addition, reset button is not clearing all the values in the form after validation. It only clears the values entered after validation.
Here is my code:
<div class="form-action clearfix">
<button type="button" onClick="clearForm()" > Reset </button>
<button class="button" type="button" id="button" onclick="doAjax('index.php/users/createUser', convertFormJson('#createUserForm'));">Create</button>
and
function clearForm() {
document.getElementById('createUserForm').reset();
}
Form:
<?php echo validation_errors(); ?>
<div class="container_12 clearfix leading" >
<div class="grid_12">
<!--<form class= "form has-validation">-->
<?php
$attributes = array('class' => 'form has-validation', 'id' => 'createUserForm');
echo form_open('/users/createUser', $attributes);
?>
<div class="clearfix">
<label for="form-name" class="form-label">First Name <em>*</em></label>
<div class="form-input">
<input type="text" id="form-name" name="firstname" required="required" placeholder="Enter the first name" value="<?php echo set_value('firstname'); ?>" />
</div>
</div>
<div class="clearfix">
<label for="form-name" class="form-label">Last Name <em>*</em></label>
<div class="form-input">
<input type="text" id="form-name" name="lastname" required="required" placeholder="Enter the last name" value="<?php echo set_value('lastname'); ?>"/>
</div>
</div>
<div class="clearfix">
<label for="form-email" class="form-label">Email <em>*</em></label>
<div class="form-input"><input type="email" id="form-email" name="email" required="required" placeholder="A valid email address" value="<?php echo set_value('email'); ?>"/></div>
</div>
<!--
<div class="clearfix">
<label for="form-birthday" class="form-label">Birthdate</label>
<div class="form-input"><input type="date" id="form-birthday" name="date" placeholder="mm/dd/yyyy" value="<?php //echo set_value('date'); ?>" class="date"/></div>
</div>
-->
<div class="clearfix">
<label for="form-username" class="form-label">Username <em>*</em></label>
<div class="form-input">
<?php echo form_error('username'); ?>
<input type="text" id="form-username" name="username" value="<?php echo set_value('username'); ?>" required="required" maxlength="30" placeholder="Alphanumeric (max 30 char.)" />
</div>
</div>
<div class="clearfix">
<label for="form-password" class="form-label">Password <em>*</em></label>
<div class="form-input">
<?php echo form_error('password'); ?>
<input type="password" id="form-password" name="password" value="<?php echo set_value('password'); ?>" maxlength="30" placeholder="Min 8 char. containing a capital, number and/or symbol" />
</div>
</div>
<div class="clearfix">
<label for="form-password-check" class="form-label">Password check <em>*</em></label>
<div class="form-input">
<?php echo form_error('passconf'); ?>
<input type="password" id="form-password-check" name="passconf" value="<?php echo set_value('passconf'); ?>" data-equals="password" maxlength="30" placeholder="Re-enter your password" />
</div>
</div>
<div class="clearfix">
<label for="form-group" class="form-label">Group <em>*</em></label>
<div class="form-input">
<?php
$groupsData[' '] = "--";
$groupJs = 'id="form-group"';
echo form_dropdown('groupId', $groupsData,' ',$groupJs);
?>
</div>
</div>
<div class="clearfix">
<label for="form-language" class="form-label" >Language <em>*</em></label>
<div class="form-input">
<select id="form-language" name="language">
<option value ="" > -- </option>
<option value ="1">English</option>
<option value ="2">French</option>
</select>
</div>
</div>
<div class="clearfix">
<label for="form-timezone" class="form-label" >Timezone <em>*</em></label>
<div class="form-input">
<?php echo timezone_menu('UM5', 'form-timezone'); ?>
</div>
</div>
Please help me out.

Categories