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">
Related
i update php form and change the value but it cant change it saves the same previous value
<tr>
<td width="22%">Course Fees</td>
<td width="38%">
<div id="total_fees">
<input type="text" class="input_text" name="total_fees" id="toal_fees" onblur="show_record(this.value,1)" value="<?php if($_POST['total_fees']) echo $_POST['total_fees']; else echo $row['total_fees'];?>" />
</div>
</td>
</tr>
Please see the screenshot of source code and input filed . i changed the value in input field but it remain same in source code and save source code value db
The input values not immediately affect on your input but You will get your new value while you submitting your form.
So submit your form and then print the values of the Request. You will find the new value of total_fees into the request parameters.
HTML CODE
<form name="jqueryForm" method="post" id="jqueryForm" enctype="multipart/form-data" onSubmit="return validme();">
<table border="0" cellspacing="15" cellpadding="0" width="100%" >
<tr>
<td width="22%">Course Fees</td>
<td width="38%">
<div id=total_fees>
<input type="text" class="input_text" name="total_fees" id="toal_fees" onblur="show_record(this.value,1)" value="<?php if($_POST['total_fees']) echo $_POST['total_fees']; else echo $row['total_fees'];?>" />
</div>
</td>
<td width="40%"></td>
</tr>
<tr>
<td width="22%">Discount in <input type="radio" name='discount_type' value="<?php if($_POST['discount_type']) echo $_POST['discount_type']; else echo percent; ?>" checked="checked" onChange="show_record()" />% or <input type="radio" name='discount_type' value="<?php if($_POST['discount_type']) echo $_POST['discount_type']; else echo cash; ?>" onChange="show_record()" />Cash</td>
<td width="38%"><input type="text" class="input_text" name="concession" id="concession" value="<?php if($_POST['concession']) echo $_POST['concession']; else if($row_record['discount'] !=0) echo $row_record['discount']; else echo 0; ?>" onBlur="show_record()"/>
</td>
<td width="40%"></td>
</tr>
</table>
<input type="submit" value="Save Record" name="save_changes" />
</form>
PHP CODE FOR SAVE IN DB
if(isset($_POST['save_changes']))
{
$total_fees=($_POST['total_fees']) ? $_POST['total_fees'] : "0";
$data_record['total_fees']=$total_fees;
$courses_id=$db->query_insert("enroll", $data_record);
}
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
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
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.
My form is not submitting, My database insert class works and I have tested. But my form seems not to want to submit or post values from my form. Is there something I left out?
<form name="form1" method="post" action="sub_newsletter.php" enctype="multipart/form-data">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2">Newsletter</td>
</tr>
<tr>
<td>Name : </td>
<td><input name="name" type="text"></td>
</tr>
<tr>
<td>Email : </td>
<td><input name="email" type="text"></td>
</tr>
<tr>
<td> <input type="text" name="check_spam" id="check_spam" size="30" style="display:none;" /> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" align="center"><input type="image" name="submit" src="images/sub.jpg" style="width:180px; height:70px;"></td>
</tr>
</form>
</table>
My submit script
<?php
include('includes/database.php');
include('includes/settings.php');
include('includes/newsletter.php');
if (isset($_POST['submit'])){
//to check if posting
echo $username=rtrim($_POST['name']);
echo $myemail=rtrim($_POST['email']);
//
$check=$_POST['check_spam'];
if(!empty($check)){ echo "You are spam"; } else{
$username=rtrim($_POST['name']);
$myemail=rtrim($_POST['email']);
$news = new Newsletter();
$new->first_name=$username;
$new->email=$myemail;
$new->create();
echo "<script>alert(\"Thank you for your subscription\"); </script>";
echo "<script>window.location.replace(\"index.html\"); </script>";
}
}
?>
You obviously missed submit button
<input type="submit" name="submit">
Since you have already a field with that name, just change it or use a different name.