Form doesn't submit all fields - php

I have a pretty huge form which I am able to extend dynamically with JavaScript. In this form I am having different DataSets with about 50 fields to submit each. When I submit the form I am running through a for loop from 0 to 100 to check which fields are set. So I create the HTML like this:
<form id = "formUpdate" role="form" action="index.php?action=update" method="post">
<table id="table" class="table table-hover"><thead>
<tr>
<th> Head1
<th> Head2
<th> Head3
<th> Head4
<th> Head5
<th> Head6
<th> ...
<tbody>
<?php
for ($i=0;$i<$dataSets;$i++){ ?>
<tr>
<td style="text-align: center; vertical-align: middle;"><label><?php echo $test[$i]['1']; ?> </label></td>
<td style="text-align: center; vertical-align: middle;"> <input required class="form-control formsUser" form="formUpdate" name="fieldA<?php echo $test[$i]['2']; ?>" value=""></input>
<td style="text-align: center; vertical-align: middle;"> <textarea style="height:34px" class="form-control formsUser" form="formUpdate" name="fieldB<?php echo $test[$i]['3'];?>" required></textarea>
<td style="text-align: center; vertical-align: middle;"> <input class="form-control formsUser" form="formUpdate" name="fieldC<?php echo $test[$i]['4']; ?>" required value=""></input>
<td style="text-align: center; vertical-align: middle;"> <input class="form-control formsUser" form="formUpdate" name="fieldD<?php echo $test[$i]['5']; ?>" required value=""></input>
<td style="text-align: center; vertical-align: middle;"> <input class="form-control formsUser" form="formUpdate" name="fieldE<?php echo $test[$i]['6']; ?>" value=""></input>
</tr>
<?php } ?>
</table>
<button class="btn btn-success" form="formUpdate" type="submit"> Submit </button>
</form>
PHP:
public function update(){
print_r($_REQUEST);
for ($i=0;$i<100;$i++){
$string = "fieldA".$i;
if (isset($_POST[$string])){
// set the other _POSTS
}
else {
//do something different
}
}
}
But this works only for the first 10 Datasets. When I call print_r($_REQUEST); it also just contains the content of the fields of the first 10 Datasets. I read about the limit of max_input_vars in the php.ini and increased this value, but nothing has changed. Besides I shouldn't reach the default value of 1,000 with my data. I also tried changing the value of max_input_nesting_level, memory_limit and post_max_size.

OMG. Got the Problem. I am using DataTables and when submitting the form, the table is redrawed showing the first 10 Datasets only...sorry for that guys and thanks for your help :)

Related

Blade view not rendering in laravel

I am developing a website where candidate entry has to be done and record search.
I have created a single Blade view file. In which there are different section which are called based on the if condition.
My Display.blade.php view is as below
<center>
#if($ID>0)
<table border="0" width="100%">
<tr>
<td>#include('Header')</td>
</tr>
<tr>
<td style="font-family:arial;font-size:30px;text-align:center;">Edit Registration</td>
</tr>
</table>
#endif
<!--First Call-->
#if($ID < 0)
<table border="0" width="100%">
<tr>
<td>#include('Header')</td>
</tr>
<tr>
<td style="font-family:arial;font-size:30px;text-align:center;">New Registration1</td>
</tr>
</table>
<form action="/Register" method="post" target="_self">
<input type = "hidden" name = "_token" value = "<?php echo csrf_token() ?>">
<table border="1" width="70%" cellpadding="3" style="border-collapse: collapse" bordercolor="#eeeeee">
<tr>
<td>First Name</br><input type="text" name="fname" /></td>
<td>Middle Name</br><input type="text" name="mname" /></td>
<td>Last Name</br><input type="text" name="lname" /></td>
<td>Contact No</br><input type="text" name="contactno" /></td>
</tr>
<tr>
<td colspan="4" align="center"><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
#endif
</center>
Header.blade.php is as below.
<style>
.container
{
background-image: url("header.jpg");
background-repeat: repeat-all;
left:0;
top:0;
width:100%;
height:80px;
}
</style>
<div class="container">
<div class="Cname">Cube Placement</div>
<div class="rTable">
<div class="rTableRow">
<div class="rTableHead">
<strong>
<a href='{!!url('/Register'); !!}'>Register</a>
</strong></div>
<div class="rTableHead"><strong>Report</strong></div>
</div>
</div>
</div>
the code execute fine. When Edit Registration section is executed CSS is missing from the page but when New Registration section is called CSS works fine.
except that everything is working correctly.
What is wrong in my code.
To make your css accessible on every page, place the css file in a folder in the public folder and use this code in the link tag where you call the css file, preferably in the file you load on every page.
{{ URL::to('/') }}/path/style.css
Here you say to the browser go to yourdomain.com/path/style.css
Hope it works for you

Refresh page give difference style result after adding form element

I found a strange behaviour in my css style. I created a login page that can be accessed from a link wihtin home page. If I access login page from a link within home page or login page itself, everything looks fine. But, whenever I refresh login page, the header looks weird. And all of this happen only if <form> element is exists, without <form> element, there's no problem.
So, what causes this to happen? And how do I fix this?
Note: Everything after this is only attachment for my question details.
The login file page written like this:
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/config/core.php'); ?>
<html>
<?php include_once($root.'/includes/head.php');?>
<body>
<div id="wrapper">
<?php include_once($root.'/includes/header.php');?>
<?php include_once($root.'/includes/navigation.php');?>
<section>
<article>
<h2>Login</h2>
<form action="<?php echo $current_file;?>" method="post">
<table align="center" border="0" cellpadding="0" cellspacing="15">
<tr>
<td width="100">Username</td>
<td>:</td>
<td><input type="text" name="username" maxlength="50" size="35"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input type="password" name="password" maxlength="50" size="35"></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" value=" Login "><input type="submit" value=" Reset "></td>
</tr>
</table>
</form>
</article>
</section>
<?php include_once($root.'/includes/news.php');?>
<?php include_once($root.'/includes/footer.php');?>
</div>
</body>
</html>
The header.php file that I included written like this:
<header>
<div id="logo">
<img src="/images/arh.png" />
<h1>The Header</h1>
</div>
</header>
And, the css file for header element is written like this:
header {
background-color: #000; height: 120px;
}
#logo {
float: left;
}
#logo img {
height: 100px; padding: 10px;
}
#logo h1 {
color: #ccc; float: right; font-size: 36px; padding: 30px;
}
The result if i access login.php page from link:
And, if i refresh the page:
i had pretty much that same problem. Matewka is right.
there was a small error in my html on my header. i had my div in the middle of my table.
What i had
<div>
<table>
<tr>
<td>
</td>
</tr>
</div>
</table>
what i changed it to
<div>
<table>
<tr>
<td>
</td>
</tr>
</table>
</div>
I just moved my div to the end of my table. I don't know how i did this, but being up for a few days or staring at the same thing over and over you start missing things. I would double check the html, it might be that simple. (are you using height % ?) do you have borders?

Jquery not adding dynamic php

I have a basic form that submits the form data to the same page and do a simple search in a MySQL db. The php for this in before the <html> tag
<body>
<div data-role="page">
<div role="main" class="ui-content">
enter code here
<table style="width:750px;">
<form enctype="multipart/form-data" action="player_documents_m.php" method="get" data-ajax="false">
<tr style="height:35px;">
<td style="width:250px; vertical-align:top; text-align:left;">
<label for="name">Player Name: </label>
</td>
<td style="text-align:left; vertical-align:middle; text-align:center;">
<input type="text" name="name" id="name" class="inputs" size="45" value="<?php echo $my_name; ?>" maxlength="255"/>
</td>
</tr>
<tr style="height:35px;">
<td style="text-align:left; vertical-align:bottom; text-align:right;" colspan="2">
<input type="submit" name="search" id="search" value="Search Player" />
</td>
</tr>
</form>
</table>
The above works in JqueryMobile
Then the results are added dynamically with html content but this does not work in JqueryMobile but taking out all JQueryMobile related stuff and leave a normal php page everything works.
Below the table tag above I add my php to add the founded search results.
<?php
for($j = 0; $j < $i; $j++)
{
$photo = "images/" . $db_new . "/players/" . $player[$j]["player_id"] . ".jpeg";
echo "<br />";
?>
<!-- Search Results -->
<div class="singleResult" onclick="javascript: window.location.replace('load_documents.php?identification=<?php echo $player[$j]["player_id"]; ?>');">
<table border="1" style="width:100%; border: solid thin; padding:0; border-spacing:0;">
<tr>
<!-- Image 1st Column -->
<td rowspan="2" colspan="1" style="width:10%; vertical-align:top; text-align:left;">
<img src="<?php echo $photo; ?>" style="width:150px; height:180px;" />
</td>
<td class="labels">Name:
<p class="results"><?php echo $player[$j]["player_name"]; ?></p>
</td>
</tr>
</table>
</div>
<!-- End Of Search Results -->
<?php
}
?>
</div>
</div>
</body>
Now the above only works normally and not in JqueryMobile. can some please explain to me what I am doing wrong / need to add, or anything helpful please.
Thanks

update query not work

This is the full code of the page which i am using to update data.I Tried many time but it still not updating values in database..also tried to echo but still not updating
<?php
session_start();
include '../func-tion/func.php';
if(isset($_SESSION['m_uname']) && isset($_SESSION['m_pass']))
{
?>
<?php
if(isset($_POST['subup']))
{
$SQL="update appid set android_appid='".$_POST['and_a']."' , iphone_appid='".$_POST['iph_a']."' , ipad_appid='".$_POST['ipa_a']."' where u_name='".$_GET['name']."'";
echo $SQL;
}
?>
<?php
$main_qry=mysql_query("select * from users where u_name='".$_GET['name']."'");
$main_fetch=mysql_fetch_assoc($main_qry);
?>
<center><h2 class="art-postheader">Edit details of <b></b></h2></center><br/><br/>
<table align="center">
<tr align="center">
<td style="height: 60px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Username:<br>
<input type="text" name="u_name" style="width: 300px;" value="<?php echo $main_fetch['u_name']?>"></td>
</tr>
<tr align="center">
<td style="height: 60px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Email:<br>
<input type="text" name="u_email" style="width: 300px;" value="<?php echo $main_fetch['u_email']?>"></td>
</tr><?php
$main_qrys=mysql_query("select * from appid where u_name='".$_GET['name']."'");
$row=mysql_fetch_assoc($main_qrys);
?> <form name="user" method="post" action="users_edit.php" onSubmit="return valid();">
<tr align="center">
<td style="width: 100px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Android Appid:<br>
<input type="text" name="and_a" style="width: 300px;" value="<?php echo $row['android_appid']?>"></td>
</tr>
<tr align="center">
<td style="width: 100px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Iphone Appid:<br>
<input type="text" name="iph_a" style="width: 300px;" value="<?php echo $row['iphone_appid']?>"></td>
</tr>
<tr align="center">
<td style="width: 100px; font-family: Helvetica,Arial,sans-serif; font-weight: bold;">Iphone(ipad) Appid:<br>
<input type="text" name="ipa_a" style="width: 300px;" value="<?php echo $row['ipad_appid']?>"></td>
</tr>
<tr align="center">
<td style="height: 28px;">
<button name="subup" type="submit">Edit</button>
</td>
</tr>
</form>
</table>
</div>
</div>
</div>
</div>
</div>
</body></html>
<?php
}
else
{
header("Location:notserver.php?l=fake");
}
?>
if anyone know..Please help me i will be very thankfull to him
Use the query:
UPDATE appid
set android_appid='$android_appid', iphone_appid='$iphone_appid', ipad_appid='$ipad_appid'
where u_name IN (select u_name from users where u_id = $_GET[id])
I wonder why you're using $_GET['id'] rather than $_POST['id'] like the other parameters in your script. Make sure that's correct. And you should check for errors from mysql_query(); if it returns false, print mysql_error() to see the reason.

Dynamically fill a html table using ajax or php from mysql DB when i click the search button

I have a table which initially get filled while page loading.Now,I have a search button to filter the table where i have post function to filter the search results but it is loading every-time i search through the text-box which is not good.I need a ajax or J son or JavaScript code to load the grid each time it is searched.
My table:
<table align="center" class="sortable" border="1" width="900px">
<tr >
<td class="sorttable_nosort" style=" font-weight:bold; text-align:center">Select</td>
<td class="sorttable_nosort" style=" font-weight:bold; text-align:center">Action</td>
<td style=" font-weight:bold;">Product Code</td>
<td style=" font-weight:bold;">Warranty Periods In Months</td>
<td style=" font-weight:bold;">ProRata Period In Months </td>
<td style=" font-weight:bold;">Manufacturer Date</td>
<td style=" font-weight:bold;">Applicable Form Date</td></tr>
<?php
// This while will loop through all of the records as long as there is another record left.
while( $record = mysql_fetch_array($query))
{ // Basically as long as $record isn't false, we'll keep looping.
// You'll see below here the short hand for echoing php strings.
// <?=$record[key] - will display the value for that array.
?>
<tr>
<td bgcolor="#FFFFFF" style=" font-weight:bold; text-align:center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $record['ProductCode']."~".$record['ManufactureDate']; ?>"></td>
<td bgcolor="#FFFFFF" style=" font-weight:bold; text-align:center"> <a style="color:#FF2222" name="edit" href="productwarrantymaster.php?<?php if(($row['editrights'])=='Yes') { echo 'ProductCode='; echo $record['ProductCode'];echo '&ManufactureDate=';echo $record['ManufactureDate'];} else echo 'permiss'; ?>">Edit</a></td>
<td bgcolor="#FFFFFF"><?=$record['ProductCode']?> </td>
<td bgcolor="#FFFFFF" ><?=$record['WarrantyPeriod']?></td>
<td bgcolor="#FFFFFF"> <?=$record['ProRataPeriod']?> </td>
<td bgcolor="#FFFFFF" > <?=$record['ManufactureDate']?> </td>
<td bgcolor="#FFFFFF" > <?=$record['ApplicableFormDate']?> </td></tr>
<?php
}
?>
</table>
I have used the pagination code too to fill the grid which is also added here.
My POST function:
if(isset($_POST['Search']))
{
if(isset($_POST['codes'])||isset($_POST['names']))
{
if(empty($_POST['codes'])&&empty($_POST['names']))
{
?>
<script type="text/javascript">
alert("Enter text Field!!");document.location='productwarrantymaster.php';
</script>
<?
}
else
{
if(!empty($_POST['codes'])&&!empty($_POST['names']))
{
$condition="SELECT * FROM productwarranty WHERE ProductCode like'%".$_POST['codes']."%' AND ManufactureDate like'".
$_POST['names']."%'";
}
else if(!empty($_POST['codes'])&&empty($_POST['names']))
{
$condition="SELECT * FROM productwarranty WHERE ProductCode like'%".$_POST['codes']."%'";
}
else if(!empty($_POST['names'])&&empty($_POST['codes']))
{
$condition="SELECT * FROM productwarranty WHERE ManufactureDate like'".$_POST['names']."%'";
}
else
{
$condition="SELECT * FROM productwarranty WHERE 1";
}
$refer=mysql_query($condition);
$myrow1 = mysql_num_rows($refer);
//mysql_fetch_array($query);
$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$limit = 10;
$startpoint = ($page * $limit) - $limit;
//to make pagination
$statement = "productwarranty";
//show records
$starvalue = $myrow1;
$query = mysql_query("{$condition} LIMIT {$startpoint} , {$limit}");
if($myrow1==0)
{
?>
<script type="text/javascript">
alert("Entered keyword not found!!");document.location='productwarrantymaster.php';
</script>
<?
}
}
}
}
My Search Table:
<div style="width:80px; height:30px; float:left; margin-left:3px; margin-top:16px;" >
<label>Product Code</label>
</div>
<div style="width:145px; height:30px; float:left; margin-left:3px; margin-top:16px;">
<input type="text" name="codes" value=""/>
</div>
<!--Row1 end-->
<!--Row2 -->
<div style="width:80px; height:30px; float:left; margin-left:3px; margin-top:9px;">
<label>Manufacturer Date</label>
</div>
<div style="width:145px; height:30px; float:left; margin-left:3px; margin-top:16px;" >
<input type="text" id="searchdate" name="names" value=""/>
</div>
<!--Row2 end-->
<div style="width:83px; height:32px; float:left; margin-top:16px;">
<input type="submit" name="Search" value="" class="button1"/>
</div>
Kindly help me out for this issue.
Thanks in Advance:P
jQuery is very good at loading data
This is the general direction you can go to achieve this:
Modify your php to output JSON: http://php.net/manual/en/function.json-encode.php
The php script stands alone. Calling the script by itself in the browser will print the JSON to the screen. jQuery will call this script and gather the output.
Remove the existing table: (Something like this) $('#mytable').remove();
Clear the table from the front-side. In the next step you will add a new one.
Getting the JSON:: http://api.jquery.com/jQuery.getJSON/
The link above shows how to call the php file and parse the JSON
Rebuild the table with jQuery. The link above also shows how to output data.

Categories