File uploading not working for larger files - php

I am trying to upload a .zip file. It is working well for small files . But I can upload files >2MB. When I try to upload files >2 MB google chrome shows in the bottom left corner as (uploadin : --%) where -- is a no like 10. But it is stuck after 14%. After some time it shows an error like "Error 101 (net::ERR_CONNECTION_RESET): The connection was reset."This web page is not available.
Please help me
This is the form code
<form name="addnewitem" id="addnewitem" method="post" enctype="multipart/form-data">
<?php if (($succ==0) && ($message!="")) { echo "<div class='error'>".$message."</div>"; } ?>
<?php if ($msg!="") { echo "<div class='success'>".$msg."</div>"; } ?>
<?php if ($msg1!="") { echo "<div class='error'>".$msg1."</div>"; } ?>
<div class="list-item">
<div class="form">
<h2>Name & Description</h2>
<div class="row">
<div class="left">
<label>Item Title:</label>
</div>
<div class="right">
<input name="listitemname" id="listitemname" type="text" class="input" maxlength="50" value="<?php echo $_POST['listitemname']; ?>" />
<em>Maximum 50 characters</em>
</div>
</div>
<div class="row">
<div class="left">
<label>
Item Description:
</label></div>
<div class="right">
<textarea name="itemdescription" id="itemdescription" cols="10" rows="5"><?php echo $_POST['itemdescription'];?></textarea>
<em>Maximum 600 characters</em>
</div>
</div>
</div>
<div class="form">
<h2>
Item Files & Preview
</h2>
<div class="row">
<div class="left">
<label>
Item Thumbnail:
</label>
</div>
<div class="right"><input type="file" name="thumbnailimage" id="thumbnailimage" class="input" />
<em>JPG or PNG, 80 x 80 Thumbail</em>
</div>
</div>
<div class="row">
<div class="left">
<label>
Item Rollover Preview:
</label></div>
<div class="right"><input type="file" name="rolloverimage" id="rolloverimage" class="input" />
<em>JPG or PNG, 190 x 190 Preview Image</em>
</div>
</div>
<div class="row">
<div class="left">
<label>
Screenshot image 1:
</label></div>
<div class="right"><input type="file" name="themepreview1" id="themepreview1" class="input" />
<em>JPG or PNG, 420 x 420 Image Screenshot ( Required )</em>
</div>
</div>
<div class="row">
<div class="left">
<label>
Screenshot image 2:
</label></div>
<div class="right"><input type="file" name="themepreview2" id="themepreview2" class="input" />
<em>JPG or PNG, 420 x 420 Image Screenshot ( Optional )</em>
</div>
</div>
<div class="row">
<div class="left">
<label>
Screenshot image 3:
</label></div>
<div class="right"><input type="file" name="themepreview3" id="themepreview3" class="input" />
<em>JPG or PNG, 420 x 420 Image Screenshot ( Optional )</em>
</div>
</div>
<div class="row">
<div class="left">
<label>
Screenshot image 4:
</label></div>
<div class="right"><input type="file" name="themepreview4" id="themepreview4" class="input" />
<em>JPG or PNG, 420 x 420 Image Screenshot ( Optional )</em>
</div>
</div>
<div class="row">
<div class="left">
<label>
Item Zip File:
</label></div>
<div class="right"><input type="file" name="itemfile" id="itemfile" class="input" />
<em>.ZIP File Only </em>
</div>
</div>
<div class="row">
<div class="left">
<label>Demo URL:</label>
</div>
<div class="right">
<input name="demourl" id="demourl" type="text" class="input" value="<?php echo $_POST['demourl']; ?>" />
<em>Enter the www.themepreviewurl.com here for the item Live Preview</em>
</div>
</div>
</div>
<div class="form">
<h2>
Category & Attributes
</h2>
<div class="row">
<div class="left">
<label>
Category:
</label></div>
<div class="right">
<?php
$getmaincategories = "SELECT category_name,category_id FROM ".$tbl_main_categories." WHERE category_status = 1";
$exec_getmaincategories = mysql_query($getmaincategories);
echo "<select name='categoryname' id='categoryname'>";
echo "<option value='' >Select a Category Now</option>";
while($rows_getmaincategories = mysql_fetch_array($exec_getmaincategories)) {
$getsubcategories = "SELECT sub_category_name,sub_category_hash FROM ".$tbl_sub_categories." WHERE sub_category_status=1 AND category_id=".$rows_getmaincategories['category_id'];
$exec_getsubcategories = mysql_query($getsubcategories);
echo "<option disabled='disabled' value='".$rows_getmaincategories['category_id']."'>".$rows_getmaincategories['category_name']."</option>";
while($rows_getsubcategories = mysql_fetch_array($exec_getsubcategories)) {
if ($_REQUEST['categoryname'] == $rows_getsubcategories['sub_category_hash']) { echo $selectedvalue = "selected='selected'"; }
echo "<option value='".$rows_getsubcategories['sub_category_hash']."' style='padding-right:inherit' $selectedvalue> -".$rows_getsubcategories['sub_category_name']."</option>";
}
}
echo "</select>";
?>
</div>
</div>
<div class="row">
<div class="left">
<label>
Compatible Browsers:<br />
use 'ctrl' to select multiples
</label></div>
<div class="right">
<select multiple="multiple" class="select" name="browsercompatiable[]" id="browsercompatiable[]">
<option value="">Select</option>
<option value="ie7" <?php if ($_REQUEST['browsercompatiable'] == "ie7") echo "selected='selected'"; ?>>IE7</option>
<option value="ie8" <?php if ($_REQUEST['browsercompatiable'] == "ie8") echo "selected='selected'"; ?>>IE8</option>
<option value="ie9" <?php if ($_REQUEST['browsercompatiable'] == "ie9") echo "selected='selected'"; ?>>IE9</option>
<option value="firefox" <?php if ($_REQUEST['browsercompatiable'] == "firefox") echo "selected='selected'"; ?>>Firefox</option>
<option value="safari" <?php if ($_REQUEST['browsercompatiable'] == "safari") echo "selected='selected'"; ?>>Safari</option>
<option value="chrome" <?php if ($_REQUEST['browsercompatiable'] == "chrome") echo "selected='selected'"; ?>>Chrome</option>
</select>
</div>
</div>
<div class="row">
<div class="left">
<label>
Files Includes:<br />
Use 'ctrl' to select multiples
</label></div>
<div class="right">
<select multiple="multiple" size="5" class="select" name="filesinclude[]" id="filesinclude[]">
<option value="">Select</option>
<option value="ie7" <?php if ($_REQUEST['filesinclude'] == "ie7") echo "selected='selected'"; ?>>PSD Files</option>
<option value="ie8" <?php if ($_REQUEST['filesinclude'] == "ie8") echo "selected='selected'"; ?>>Documentation</option>
<option value="ie9" <?php if ($_REQUEST['filesinclude'] == "ie9") echo "selected='selected'"; ?>>Multiple Layouts</option>
<option value="firefox" <?php if ($_REQUEST['filesinclude'] == "firefox") echo "selected='selected'"; ?>>Multiple Colour Options</option>
<option value="safari" <?php if ($_REQUEST['filesinclude'] == "safari") echo "selected='selected'"; ?>>Video Help Files</option>
<option value="chrome" <?php if ($_REQUEST['filesinclude'] == "chrome") echo "selected='selected'"; ?>>Other</option>
</select>
</div>
</div>
<div class="row">
<div class="left">
<label>
Columns:
</label></div>
<div class="right">
<select name="noofcolumns" id="noofcolumns">
<option value="">Select</option>
<option value="1" <?php if ($_REQUEST['noofcolumns'] == "1") echo "selected='selected'"; ?>>1</option>
<option value="2" <?php if ($_REQUEST['noofcolumns'] == "2") echo "selected='selected'"; ?>>2</option>
<option value="3" <?php if ($_REQUEST['noofcolumns'] == "3") echo "selected='selected'"; ?>>3</option>
<option value="4" <?php if ($_REQUEST['noofcolumns'] == "4") echo "selected='selected'"; ?>>4</option>
<option value="5" <?php if ($_REQUEST['noofcolumns'] == "5") echo "selected='selected'"; ?>>5</option>
</select>
</div>
</div>
<div class="row">
<div class="left">
<label>
Layout:
</label></div>
<div class="right">
<select name="layout" id="layout">
<option value="">Select</option>
<option value="1" <?php if ($_REQUEST['layout'] == "1") echo "selected='selected'"; ?>>1</option>
<option value="2" <?php if ($_REQUEST['layout'] == "2") echo "selected='selected'"; ?>>2</option>
<option value="3" <?php if ($_REQUEST['layout'] == "3") echo "selected='selected'"; ?>>3</option>
<option value="4" <?php if ($_REQUEST['layout'] == "4") echo "selected='selected'"; ?>>4</option>
<option value="5" <?php if ($_REQUEST['layout'] == "5") echo "selected='selected'"; ?>>5</option>
</select>
<em>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus id arcu vitae eros molestie ultricies ut sit amet nisi. Nulla facilisi.</em>
</div>
</div>
</div>
<div class="form">
<h2>Tags</h2>
<div class="row">
<div class="left">
<label>Tags:</label>
</div>
<div class="right">
<textarea name="itemtags" id="itemtags" cols="10" rows="5"><?php echo $_POST['itemtags']; ?></textarea>
<em>Maximum 50 characteres</em>
</div>
</div>
</div>
<div class="botton">
<input name="additem" id="additem" type="submit" value="Upload Now" class="btn" />
</div>
</div>
</form>
And I would like to upload >3MB files in the .zip field shown below
<div class="right"><input type="file" name="itemfile" id="itemfile" class="input" />
<em>.ZIP File Only </em>
</div>

Check upload_max_filesize, max_input_time, and post_max_size in your php.ini
If the file size is very large, you may need to bump memory_limit as well.

change php.ini change size and test your script.(php.ini resides in php installation directory)
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
to
upload_max_filesize = Required_size M

Please check that your "max_input_time" option in your server is not too low, it might be why PHP is cutting you off. Else it could be a server/network infrastructure related issue:
echo ini_get('max_input_time');
If you get -1 from this, it is most probably not PHP cutting you off but something else in the loop. It can be any piece of hardware on the way to your server, but most probably the server itself or something at the server place...

For large files, if you don't want to have to deal with configuring server settings (particularly if you are on shared hosting or some other hosting that doesn't give you full control over the server), one potential solution is to hand the upload off to a third party service.
For example, you could have the form do a direct post to Amazon S3 (http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html) or use a service like Filepicker.io
Full disclosure: I work at Filepicker.io, but want to help out folks who are dealing with issues doing large file uploads

Related

Select Dropdown Automatically According to value from Database

I have very simple dropdown menu like below in my PHP page.
<div class="form-group">
<label class="col-md-3 control-label">FAQ Type :-</label>
<div class="col-md-6">
<select name="faq_type" id="faq_type" class="select2" required>
<option value="0">Text</option>
<option value="1">Image</option>
<option value="2">Video</option>
</select>
</div>
</div>
I want select Text, Image or Video selection automatically according to value I get from database, for other field I am able to echo like below
<div class="col-md-6">
<textarea name="question" id="question" rows="1" class="form-control" ><?php if(isset($_GET['faq_id'])){echo $row['question'];}?></textarea>
</div>
How can I do same for dropdown ?
Edit : according to answer, I was able to do it but I have one small another issue in it, I want only set selected if if(isset($_GET['faq_id'])) else want show normal all button as currently I am showing as above.
<div class="form-group">
<label class="col-md-3 control-label">FAQ Type :-</label>
<div class="col-md-6">
<?php
if(isset($_GET['faq_id'])) {
<select name="faq_type" id="faq_type" class="select2" required>
<option value="0" <?php if($row['type'] == "0") echo "selected"; ?>>Text</option>
<option value="1" <?php if($row['type'] == "1") echo "selected"; ?>>Image</option>
<option value="2" <?php if($row['type'] == "2") echo "selected"; ?>>Video</option>
</select>
} else {
}
?>
</div>
</div>
if I do like this, its giving me error like below
Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\new\add_faq.php on line 169
Thanks
For drop down you can set selected field like this
<div class="form-group">
<label class="col-md-3 control-label">FAQ Type :-</label>
<div class="col-md-6">
<select name="faq_type" id="faq_type" class="select2" required>
<option value="0" <?php if($row['your_db_field'] == "0") { ?> selected="selected" <?php } ?> >Text</option>
<option value="1" <?php if($row['your_db_field'] == "1") { ?> selected="selected" <?php } ?> >Image</option>
<option value="2" <<?php if($row['your_db_field'] == "3") { ?> selected="selected" <?php } ?> >Video</option>
</select>
</div>
</div>

Code Igniter - Select tag option depending on another select tag value

I'm new in CodeIgniter and still junior in programming, so don't be angry at me.
PS: don't be angry for my English too. ;)
I am creating small CMS for one project. Inside that project its few select tags, first ones have just a few values but the next ones, have many values, which depends to the one of the values, from select tag that i mention before.
Its everything ok with my database tables dependencies, etc. but I dont know how to make dependencies to show up in select tags. I tried to make it with Ajax, but I am still not make it, and I read that I can make it with codeIgniter libraries, is it true? Can any body can help me?
This is my view file:
<?php echo validation_errors('<p class="alert alert-dismissable alert-danger">'); ?>
<form method="post" action="<?php echo base_url(); ?>admin/engines/add">
<div class="row">
<div class="col-lg-6">
<h1>Engine Type</h1>
</div>
<div class="col-lg-6">
<div class="btn-group pull-right">
<input type="submit" name="submit" class="btn btn-success" value="Save">
Close
</div>
</div>
</div><!-- /.row -->
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<li><i class="fa fa-dashboard"></i>Dashboard</li>
<li><i class="fa fa-pencil"></i>Variklio Tipai</li>
<li class="active"><i class="fa fa-plus-square-o"></i>Pridėti Variklio tipą</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<h2>Engine type One</h2>
<div class="form-group">
<label>Engine Name</label>
<input class="form-control" type="text" name="engine" value="<?php echo set_value('engine'); ?>" placeholder="Engine Type" >
</div>
<div class="form-group">
<label>Category</label>
<select name="brand" class="form-control">
<option value="category">Choose category</option>
<?php foreach($categories as $category) : ?>
<option value="<?php echo $category->id; ?>"><?php echo $category->category_name; ?></option>
<?php endforeach; ?>
</select>
</div>
<!-- END Category-->
<!-- *** Brand *** -->
<div class="form-group">
<label>Brand</label>
<select name="brand" class="form-control">
<option value="">Choose Brand</option>
<?php foreach ($brands as $brand) : ?>
<option value="<?php echo $brand->id; ?>"><?php echo $brand->v_brand_name; ?></option>
<?php endforeach; ?>
</select>
</div>
<!-- **** END Brand ***-->
<!-- *** Model *** -->
<div class="form-group">
<label>Model</label>
<select name="model" class="form-control">
<option value="">Choose model</option>
<?php foreach ($models as $model) : ?>
<option value="<?php echo $model->id; ?>"><?php echo $model->v_model_name; ?></option>
<?php endforeach; ?>
</select>
</div>
<!-- **** END MODEL ***-->
</div>
</div>
</div>
</form>
for example this is my view
<select name='list1' id='list1'>
<option value='1'>id 1</option>
<option value='2'>id 2</option>
<option value='3'>id 3</option>
<option value='4'>id 4</option>
<option value='5'>id 5</option>
</select>
this is 2nd dropdown list
<select name='list2' id='list2'>
</select>
now jquery code is
$("#list1").on("change",function(){
var value = $(this).val();
$.ajax({
url : "example.com/welcome/get_data",
type: "post",
data: {"value":value},
success : function(data){
$("#list2").html(data);
},
});
});
now my controller function is
public function get_data()
{
$value = $this->input->post("value");
$data = $this->mymodal->get_data($value);
$option ="";
foreach($data as $d)
{
$option .= "<option value='".$d->id."' >".$d->name."</option>";
}
echo $option;
}
my model function is
public function get_data($value)
{
$this->db->where("id",$value);
return $this->db->get("table_name")->result();
}

get the dynamically created multiple select box values using jquery

I have been reviewing a lot of pages about this and can't seem to figure out why this isn't working.
And I have a doubt in the section of,if i have multiple dynamically created select box and this selected values to be passed to the text box with some calculation before using jQuery. please help me i have tortured in this section.
In the below line of input.php have the html code of get the input.
function addMore() {
$("<DIV>").load("input.php", function() {
$("#product").append($(this).html());
});
}
function deleteRow() {
$('DIV.product-item').each(function(index, item){
jQuery(':checkbox', this).each(function () {
if ($(this).is(':checked')) {
$(item).remove();
}
});
});
}
$(document).ready(function() {
$('.product-item').change(function()
{
var option1 =$(this).find('.orderbox1 option:selected').val();
var option2 = $(this).find('.orderbox2 option:selected').val();
option1 *= $(".orderbox3").val();
option2 *= $(".orderbox3").val();
$(".orderbox4").val(option1-option2);
});
});
</SCRIPT>
</HEAD>
<BODY>
<FORM name="frmProduct" method="post" action="">
<DIV id="outer">
<DIV id="header">
<DIV class="float-left" style="margin-left:150px;"> </DIV>
<DIV class="float-left col-heading">Choose Currency</DIV>
<DIV class="float-left col-heading">Choose Product</DIV>
<DIV class="float-left col-heading">Forex Amount</DIV>
<DIV class="float-left col-heading">Rupee Amount</DIV>
</DIV>
<DIV id="product">
<DIV class="product-item float-clear" style="clear:both;">
<DIV class="float-left"><input type="checkbox" name="item_index[]" /></DIV>
<DIV class="float-left"> Choose Currency:
<select name="item_currency[]" id="orderbox1" class="orderbox1" style="width:150px;">
<option selected="selected">Select</option>
<option value="66">United States</option>
<option value="75">European</option>
<option value="12">Philippines</option>
<option value="17">Qatar</option>
</select></DIV>
<DIV class="float-left"> Choose Product:
<select name="item_size[]" id="orderbox2" class="orderbox2">
<option value="1" selected="selected">Select</option>
<option value="10">Forex Card</option>
<option value="20">Currency Notes</option>
</select></DIV>
<DIV class="float-left"><input type="text" name="item_name[]" id="orderbox3" class="orderbox3"/></DIV>
<DIV class="float-left"><input type="text" name="item_price[]" id="orderbox4" class="orderbox4"/></DIV>
</DIV>
</DIV>
<DIV class="btn-action float-clear">
<input type="button" name="add_item" value="Add More" onClick="addMore();" />
<input type="button" name="del_item" value="Delete" onClick="deleteRow();" />F
<span class="success"><?php if(isset($message)) { echo $message; }?></span>
</DIV>
<DIV class="footer">
<input type="submit" name="save" value="Save" />
</DIV>
</DIV>
</FORM>
Firstly, it looks like you are trying to attach a change handler to a div. This is not possible. From the documentation -
The change event is sent to an element when its value changes. This event is limited to <input> elements, <textarea> boxes and <select> elements.
To get it to work you can change this -
$('.product-item').change(function() {
to -
$('.product-item select, .product-item input').change(function() {
Secondly, to handle dynamic rows you you need to use event delegation. Using .on you can apply the function to dynamic elements. You will need to change the function to -
$("#product").on('change', '.product-item select, .product-item input', function() {
var $line = $(this).parents('.product-item');
var option1 = $line.find('.orderbox1').val();
var option2 = $line.find('.orderbox2').val();
option1 *= $line.find(".orderbox3").val();
option2 *= $line.find(".orderbox3").val();
$line.find(".orderbox4").val(option1 - option2);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<DIV id="product">
<DIV class="product-item float-clear" style="clear:both;">
<DIV class="float-left">
<input type="checkbox" name="item_index[]" />
</DIV>
<DIV class="float-left">Choose Currency:
<select name="item_currency[]" id="orderbox1" class="orderbox1" style="width:150px;">
<option selected="selected">Select</option>
<option value="66">United States</option>
<option value="75">European</option>
<option value="12">Philippines</option>
<option value="17">Qatar</option>
</select>
</DIV>
<DIV class="float-left">Choose Product:
<select name="item_size[]" id="orderbox2" class="orderbox2">
<option value="1" selected="selected">Select</option>
<option value="10">Forex Card</option>
<option value="20">Currency Notes</option>
</select>
</DIV>
<DIV class="float-left">
<input type="text" name="item_name[]" id="orderbox3" class="orderbox3" />
</DIV>
<DIV class="float-left">
<input type="text" name="item_price[]" id="orderbox4" class="orderbox4" />
</DIV>
</DIV>
<DIV class="product-item float-clear" style="clear:both;">
<DIV class="float-left">
<input type="checkbox" name="item_index[]" />
</DIV>
<DIV class="float-left">Choose Currency:
<select name="item_currency[]" id="orderbox1" class="orderbox1" style="width:150px;">
<option selected="selected">Select</option>
<option value="66">United States</option>
<option value="75">European</option>
<option value="12">Philippines</option>
<option value="17">Qatar</option>
</select>
</DIV>
<DIV class="float-left">Choose Product:
<select name="item_size[]" id="orderbox2" class="orderbox2">
<option value="1" selected="selected">Select</option>
<option value="10">Forex Card</option>
<option value="20">Currency Notes</option>
</select>
</DIV>
<DIV class="float-left">
<input type="text" name="item_name[]" id="orderbox3" class="orderbox3" />
</DIV>
<DIV class="float-left">
<input type="text" name="item_price[]" id="orderbox4" class="orderbox4" />
</DIV>
</DIV>
</DIV>
</DIV>
Here I'm creating a variable ($line) to represent the row. I can then use find to get the orderboxes for that row.

Retain Select Box selection even after the form is submitted in php

I have a page which contains a select box which is used to select a particular user. I also have two radiobuttons for selecting date range. This page is for generating user reports based on the selections.
At present when I select the user and preferred date ranges and clicks on submit button reports are generated properly but my selection in select box will be reset to default after submitting.Here My select box is populated from mysql table.
My task is to retain the select box value even after form submit. I have tired so many ways but nothing worked. Can anyone please help me out with this..
Here is my code:
HTML
<div class="box-container-toggle">
<form class="form-horizontal" name="reportform" id="reportform" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST" >
<div class="box-content">
<fieldset>
<legend>Developer Reports</legend>
<div class="control-group">
<label class="control-label" for="select01">Select Developer</label>
<div class="controls">
<select id="select01" class="chzn-select" name="selectdev" onChange="getapp(this.value)">
<option value="">Select developer</option>
<?php
$qry="select user_id from tab_user_login where type='Developer' and status='approved'";
$res=mysql_query($qry);
while($row=mysql_fetch_array($res))
{
$devid=$row[0];
$qry1="select name from tab_user where user_id='$devid'";
$res1=mysql_query($qry1);
while($row1=mysql_fetch_array($res1))
{
?>
<option value="<?php echo $devid;?>" <?php if($dev!="") { if($dev==$devid) {echo 'selected'; } } ?> ><?php echo $row1[0];?></option>
<?php
}
}
?>
</select>
</div>
</div>
<h3> Select Date Range </h3>
<div class="control-group">
<div class="controls">
<label>
<input type="radio" name="selectdateradio" value="selectdaterange" onChange="enableblock()"> Select a Date Range
<div class="control-group" id="daterange" style="display:none">
<label class="control-label" for="select01">Select Date</label>
<div class="controls">
<select id="select01" name="selectdate" id="selectdate" onChange="getYesterdaysDate(this.value)">
<option value="Today" >Today</option>
<option value="Yesterday" >Yesterday</option>
<option value="Last 7 Days" >Last 7 Days</option>
<option value="Last 30 Days" >Last 30 Days</option>
<option value="This Week" >This Week</option>
<option value="This Month" >This Month</option>
<!--<option value="Last 6 Months" >Last 6 Months</option>-->
</select>
<input type="hidden" name="hiddendate" value="" >
<input type="hidden" name="hiddennext" value="" >
</div>
</div>
</label>
<label>
<input type="radio" name="selectdateradio" value="selectcustomdate" onChange="enablecustomblock()"> Select Custom Date
<div class="control-group" id="customdaterange" style="display:none">
<div class="control-group">
<label class="control-label" for="date01">Start input</label>
<div class="input-append date datepicker" data-date="2012-02-12" data-date-format="yyyy-mm-dd">
<input name="start_date" id="start_date" type="text"/><span class="add-on "><i class="icon-calendar"></i></span>
</div>
<!--<div class="controls">
<input type="text" class="input-xlarge datepicker" name="start_date" id="start_date" onChange="show()"/>
</div>-->
</div>
<div class="control-group">
<label class="control-label" for="date01">End Date</label>
<div class="input-append date datepicker" data-date="2012-02-12" data-date-format="yyyy-mm-dd">
<input name="end_date" id="start_date" type="text"/><span class="add-on "><i class="icon-calendar"></i></span>
</div>
<!-- <div class="controls">
<input type="text" class="input-xlarge datepicker" name="end_date" id="end_date" onChange="show()"/>
</div> -->
</div>
</div>
</label>
</div>
</div>
<div class="form-actions">
<input type="submit" class="btn btn-primary" name="submit" value="Run Reports" >
<button type="reset" class="btn">Reset</button>
</div>
</fieldset>
</div>
</form>
<?php
if(isset($_POST['submit']))
{
$dev=$_POST['selectdev'];
$qryy1="select name from tab_user where user_id='$dev'";
$ress1=mysql_query($qryy1);
$roww1=mysql_fetch_array($ress1);
$devname=$roww1[0];
$selected=$_POST['selectdateradio'];
$customstart=$_POST['start_date'];
$customend=$_POST['end_date'];
$postdate=$_POST['selectdate'];
$hide=$_POST['hiddendate'];
$hidden=date("Y-m-d", strtotime($hide));
$hide1=$_POST['hiddennext'];
$hidden1=date("Y-m-d", strtotime($hide1));
date_default_timezone_set("Asia/Kolkata");
$today=date('Y-m-d');
/*$click=0;
$imp=0;
$install=0;
$rev=00.00;
$active=0;*/
}
else
{
}
if($_POST['selectdev']=='')
$devname='All Developer';
if($_POST['selectdate']=='')
$postdate="";
?>
</div>
You must set posted variable before generate the select elements. then you can check the current developer
please try this code before generate select element (for example above the <div class="box-container-toggle"> ) :
<?php
if(isset($_POST['selectdev']) && $_POST['selectdev']!='') {
$selectdev = $_POST['selectdev'];
}
?>
Then Use your checking condition as below
<select id="select01" class="chzn-select" name="selectdev" onChange="getapp(this.value)">
<option value="">Select developer</option>
<?php
$qry="select user_id from tab_user_login where type='Developer' and status='approved'";
$res=mysql_query($qry);
while($row=mysql_fetch_array($res))
{
$devid=$row[0];
$qry1="select name from tab_user where user_id='$devid'";
$res1=mysql_query($qry1);
while($row1=mysql_fetch_array($res1))
{
?>
<option value="<?php echo $devid;?>" <?php if(isset($selectdev) && $selectdev==$devid) echo 'selected="selected"'; ?> ><?php echo $row1[0];?></option>
<?php
}
}
?>
</select>

406 not acceptable error on form submit

I have web script that shows
406 Not Acceptable Error
An appropriate representation of the requested resource /admincp/settings.php could not be found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
Problem is it works on some hosting providers. Can anyone tell me why is this error coming
<?php
$act=isset($_GET['act'])?$_GET['act']:"";
if($act=='sub'){
$name = $mysqli->escape_string($_POST['site']);
$siteurl = $mysqli->escape_string($_POST['siteurl']);
$keys = $mysqli->escape_string($_POST['keywords']);
$desc = $mysqli->escape_string($_POST['descrp']);
$email = $mysqli->escape_string($_POST['email']);
$active = $mysqli->escape_string($_POST['active']);
$template = $mysqli->escape_string($_POST['template']);
$mysqli->query("UPDATE settings SET name='$name',siteurl='$siteurl',keywords='$keys',descrp='$desc',email='$email',active='$active',template='$template' WHERE id=1");
if($_FILES["file"]["name"]!=''){
move_uploaded_file($_FILES["file"]["tmp_name"], "../images/logo.png");
}?>
<div class="msg-ok">updated successfully.</div>
<?php }
if($settings = $mysqli->query("SELECT * FROM settings WHERE id='1'")){
$setrow = mysqli_fetch_array($settings);
$name=$setrow['siteurl'];
$settings->close();
}else{
printf("Error: %s\n", $mysqli->error);
}
?>
<form action="settings.php?act=sub" method="post" enctype="multipart/form-data">
<label class="artlbl">Site Name</label>
<div class="formdiv">
<input type="text" name='site' value='<?php echo $setrow['name']?>'/>
</div>
<label class="artlbl">Logo (182px x 47px)</label>
<div class="formdiv">
<input type='file' class="file" name='file'/>
</div>
<div class="clear"></div>
<label class="artlbl">Site URL (without "http://" and end "/")</label>
<div class="formdiv">
<input type="text" name='siteurl' value='<?php echo $setrow['siteurl']?>'/>
</div>
<div class="clear"></div>
<label class="artlbl">Meta Keywords (Separated by Commas)</label>
<div class="formdiv">
<textarea name='keywords' cols=40 rows=5 ><?php echo $setrow['keywords']?></textarea>
</div>
<label class="artlbl">Meta Description</label>
<div class="formdiv">
<textarea name='descrp' cols=40 rows=5 ><?php echo $setrow['descrp']?></textarea>
</div>
<label class="artlbl">Email</label>
<div class="formdiv">
<input type="text" name='email' value='<?php echo $setrow['email']?>'/>
</div>
<label class="artlbl">Approve</label>
<div class="formdiv">
<select name="active" id="active">
<?php if ($setrow['active']==1){?>
<option value="1">ON</option>
<option value="0">OFF</option>
<?php }else{?>
<option value="0">OFF</option>
<option value="1">ON</option>
<?php }?>
</select>
</div>
<div class="clear"></div>
<label class="artlbl">Template</label>
<div class="formdiv">
<select name="template" id="template">
<option value="<?php echo $setrow['template'];?>"><?php echo ucfirst($setrow['template']);?></option>
<?php
foreach(glob('../templates/*', GLOB_ONLYDIR) as $dir) {
$TemplateDir = substr($dir, 13);
$TemplateName = ucfirst($TemplateDir)
?>
<option value="<?php echo $TemplateDir;?>"><?php echo $TemplateName;?></option>
<?php }?>
</select>
</div>
<div class="clear"></div>
</br>
<div class="formdiv">
<div class="sbutton"><input type="submit" id="submit" value="Update Site Settings"/></div>
</div>
</form>
<select name="active" id="active"> , can you change name as well as id to something other than active , as active is a keyword.
this problem is caused by apache's mod_security, it scan the request and block it if it contain links.
try to submit this value of $_POST['siteurl'] without the http:// part, that will solve the problem in that case, but you should still contact your hosting provider about that issue.

Categories