I have a form which was working fine earlier. After a server upgrade to PHP 5.3 I now have a problem.
When my loop in the form (number of products) exceeds 9 or 10 lines, the form data is then lost, when sending it to the server.
What can be the problem? I am unable to understand why smaller loops are processed nicely and longer ones are not.
Below I have added some small parts of the code to show how the form is built.
<table id="top_header" class="pop_up" cellspacing="10" cellpadding="5" width="100%">
<tr class="floating header">
<td class="regel"><?php echo $lang['regel']; ?></td>
</tr>
<tr>
<td class="regel">
<input type="text" name="regel[]" value="<?php echo $regel; ?>" size="1" style="background-color: #e7e7e9" readonly="readonly" />
</td>
</tr>
<tr>
<td><input type="submit" class="btn_ok" onclick="this.disabled=true,this.form.submit();" value="<?php echo $lang['form_submit']; ?>" /> <input type="reset" class="btn_rst" value="<?php echo $lang['form_cancel']; ?>" /></td>
</tr>
</table>
<?php
$regel= trim(mysql_real_escape_string($_POST['regel']));
?>
I have also added the complete file to http://www.thure.nl/php_test/calculatie_plaat_edit.rar
Related
Query 1.
form submitting working fine in local , but not working in live. I removed the action and put # and also i didn't call any script for redirect but while click the submit button it is automatically redirect to the same page. i don't know how it is redirecting ?
Query 2.
In action i mentioned <?php echo $_SERVER['PHP_SELF']; ?> and also gave direct url . if i print the post value it is not coming to POST .
In both ways it is showing the error
This page isn’t working
www.XXXXXXXXXXX.com didn’t send any data.
here below i paste my short code
<?php
ob_start();
session_start();
$_SESSION['captcha'] = rand(1000,9999);
include("./config/dbconnect.php");
include("./functions/functions.php");
if($_POST){
print_r($_POST); exit;
}
?>
<table border="0" width="100%"><tr><td style="padding-left:25px">
<form name="register" method="post" action="#" enctype="multipart/form-data">
<table width="634" border="0">
<tr>
<td colspan="3" class="sub_heading"><div align="right"><span class="style_r">* Mandatory Fields</span></div></td>
</tr>
<tr>
<td height="24" colspan="3"><div align="left" class="sub_heading">Login Information</div></td>
</tr>
<tr>
<td width="178">Email<span class="style_r">*</span></td>
<td width="10">:</td>
<td width="432"><input type="text" name="email" width="14" maxlength="50" /></td>
</tr> ******************* etc <tr>
<td colspan="3"><input type="checkbox" name="terms" />
I have read, understood and agree to the Terms and Conditions of eGulfCareers.com</td>
</tr>
<tr>
<td width="178"></td>
<td width="10"></td>
<td width="432"><input type="hidden" name="register" value="1" />
<input type="submit" name="submit" value="Signup" class="submit_button" /></td>
</tr>
</table>
</form></td>
</tr>
</table> `
I'm trying to make a movie theatre webpage. Very nooby, with almost no PHP and HTML experience. We are learning in school, and we are just using Adobe Dreamweaver to insert stuff like recordsets, bindings, tables etc.
Now I want to make the page where the user can order a ticket, I've created a form, however it only inserts the value of one ticket(obv). I want to make the price to show for 1 ticket, but be stored in MySQL database as price*amount of tickets. I'd be very happy if someone could help me out here:
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Pris_kr:</td>
<td><?php echo $row_Recordset1['pris_kr']; ?> pr billett<input type="hidden" value="<?php $row_Recordset1['pris_kr']*$row_antall_billetter;?>"/></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Personid:</td>
<td><select name="personid">
<?php
do {
?>
<option value="<?php echo $row_Recordset1['personid']?>" ><?php echo $row_Recordset1['epost']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
?>
</select></td>
</tr>
<tr> </tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Antall_billetter:</td>
<td><input type="text" name="antall_billetter" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Rad:</td>
<td><input type="text" name="rad" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Sete:</td>
<td><input type="text" name="sete" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="bestillingsid" value="" />
<input type="hidden" name="visningsid" value="<?php echo $_GET['visningsid']; ?>" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
again, I'm a newbe and I'm aware of the fault in the code:
<td nowrap="nowrap" align="right">Pris_kr:</td>
<td><?php echo $row_Recordset1['pris_kr']; ?> pr billett<input type="hidden" value="<?php $row_Recordset1['pris_kr']*$row_antall_billetter;?>"/></td>
Am I heading towards something that could help me though?
I'm also using two views here, to get the right time and date, so the url parameters here are "visningsid" and "bestillingsid".
Some translations:
Pris_kr=Price in kr, Antall_billetter=Amount of tickets
The others are not very important I guess.
Thanks in advance
//Sander
here is only part of my code, the action does not well ...action. when i view in the google javascript tools i have an id in the action line
when i hit the submit button, nothing happens, its suppose to go to php/form.php with ID 28 in this instance
......
if (mysqli_num_rows($result))
{
while ($row = mysqli_fetch_assoc($result))
{
?>
<form name="form-list" method="post" action='php/form.php?id=<?php echo $row["id"]; ?>' >
<table>
<tr>
<td valign="top">
<label for="surname">Surname</label>
</td>
<td valign="top">
<?php echo $row["title"]; ?>
</td>
</tr>
<tr>
<td valign="top">
<label for="name">Id</label>
</td>
<td valign="top">
<input type="text" value='<?php echo $row["id"]; ?>' name="name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<input type="button" value="Submit" />
</td>
</tr>
<?php } } ?>
</table>
</form> .....
<input type="submit" value="Submit" />
The input type is not button it is submit.
The value attribute just changes the written text on the button but does not change it's behavior.
Note to the other answers:
Using POST is fine if he handles the request in the right way. In the given code example everything except the submit button works and is fine.
In this case the id is transmitted as a GET and all other values are submitted via POST. You can mix them.
Later you do have to use $_GET["id"] and $_POST["name"].. or you can even use $_REQUEST["..."] for all of them.
A simple test program program is included.
enter data into dataone
click on create system
dataone data moved to datatwo
works with 5.3
with 5.4 when the create system image is clicked
the data in dataone disappears from the form and noting is passed to datatwo
we have a large number of programs that use this method of input fields and images to click on.
If I shift to 5.3 it works.
If I shift to 5.4 it wil not work.
<!DOCTYPE HTML>
</head>
<?php
$dataone = $HTTP_POST_VARS['dataone'];
$datatwo = $HTTP_POST_VARS['datatwo'];
if(isset($_POST['proc_x']))
{
$datatwo = $dataone;
}
?>
<form name="form1" method="post" action="test.php">
<table>
<tr>
<td><strong>
One</strong>
</td>
</tr>
<tr>
<td colspan="2"><input name="dataone" type="text" id="dataone"
value="<?php echo $dataone?>" size="70">
</td>
</tr>
<tr>
<td><strong>
two</strong>
</td>
</tr>
<tr>
<td colspan="2"><input name="datatwo" type="text" id="datatwo"
value="<?php echo $datatwo; ?>" size="70">
</td>
</tr>
</table>
<table>
<tr>
<td colspan="1"><div align="left" >
<input name="proc" type="image" id="proc" value="proc" alt="Create System"
title="Create System" width="25" height="25">
<strong>proc</strong></div>
</td>
</tr>
</table>
<table>
<tr>
<td colspan="2"><input name="inx" type="hidden" id="inx"
value ="<?php echo $inx; ?>" size="100">
</td>
</tr>
</table>
</form>
</body>
</html>
$HTTP_POST_VARS was deprecated long ago. I haven't actually seen anyone use it in nearly 10 years. Use $_POST instead.
Also, you have opened yourself up to potential XSS attacks. Always use htmlspecialchars() around any arbitrary data used in the context of HTML.
I am using the current code
<form method="post" action="<?php echo $PHP_SELF;?>">
<tr>
<td>Enter joker number:</td>
<td align="center"><input type="text" VALUE="<?php $joker ?>" name="joker"
size="3" maxlength="3"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit Order"></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['joker'])){
$joker = $_POST['joker'];}
?>
For the data entry of a form. Since this saves data as $joker in the php portion of my code, I was hoping that <?php $joker ?> would allow the previous data to be left on screen, but it didn't work. Any idea on how to refine my code?
Use your original code but move the php section above the HTML form code. And add echo in the embedded php directive.
Also set $joker as empty string or anything default at the top of the php code.
<?php
$joker = "";
if(isset($_POST['joker'])){
$joker = $_POST['joker'];}
?>
<form method="post" action="<?php echo $PHP_SELF;?>">
<tr>
<td>Enter joker number:</td>
<td align="center"><input type="text" VALUE="<?php echo $joker; ?>" name="joker" size="3" maxlength="3"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit Order"></td>
</tr>
</table>
</form>
Write only echo in php code before $joker. Thats it.
Do like following:
<input type="text" VALUE="<?php echo $joker ?>" name="joker"
size="3" maxlength="3">