I want to bring many $_REQUEST from Tag but only $_REQUEDT['editid'] works. how to solve it.
echo "<td><a href=product.php?editid=$id, editname=$name, editqty=$qty, editprice=$price>Edit</a></td>";
//when I put $_REQUEST['editid'] in input it works but others not.
<form action="product.php">
<table>
<tr>
<td>ID</td>
<td><input type="text" name="tid" value="<?php if(isset($_REQUEST['editid'])){echo $_REQUEST['editid'];} ?>"></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="tname" value="<?php if(isset($_REQUEST['editname'])){echo $_REQUEST['editname'];}?>"></td>
</tr>
<tr>
<td>Qty</td>
<td><input type="text" name="tqty" ></td>
</tr>
<tr>
<td>Price</td>
<td><input type="text" name="tprice" ></td>
</tr>
<tr>
<td></td>
<td><button type="submit" name="btn-add">Add</button>
<button type="submit" name="btn-clear">Clear</button></td>
</tr>
</table>
</form>
The URL parameters after the 1st one should be separated by & (not ,)
Change from
<a href=product.php?editid=$id, editname=$name, editqty=$qty, editprice=$price>
to
<a href="product.php?editid=$id&editname=$name&editqty=$qty&editprice=$price">
Related
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 what I am trying to do. I have a dropdown (and or excel type look) that I need to pull data from the database. When I have an item selected I need to pass the info to the next page via a session. I have the drop down pulling from the database but I need to list Name and address in the dropdown.
If this is not possible I can do a list of items from a search but I will need to make the id a link to pass the id to the next page where I need to build a report.
If you can give me some info on this I would appreciate it.
Here is what I have for code on the dropdown
Code: Select all
<?php
// declare database connection variables.
$host = "localhost";
$username = "root";
$password = "";
$db_name = "sample";
$tbl_name = "tbl_report";
// connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql = "SELECT id, name, address FROM $tbl_name";
$result = mysql_query($sql) or die(mysql_error());
$dropdown = "<form action='report.php' method='post'>";
$dropdown .= "<select name='items' class='select'>";
while ($row = mysql_fetch_assoc($result)) {
$dropdown .= '<option value="' . $row['id'] . '">' .
$row['name'] . ' - ' . $row['address'] . '</option>';;
}
$dropdown .= "\r\n</select>";
$dropdown .= "<input type='submit' name='submit' value='Submit'>";
$dropdown .= "</form>"; //closing the form tag
echo $dropdown;
?>
What I need to do is pass the ID to the next page and have the $id show up in the code for my next sql statement.
Here is the code that I have for the next page sql statement.
select * from $tbl_name where id = (this is where I get hung up on.)
What I need is a way to pass the $row['id'] to the next page and put that in the sql code and then use the get method to display the info on the form of that page.
Here is the setup of the pages. select-report.php (this is where the drop down is) --> report.php.
Here is the form for report.php where i need to carry over the value of id and do a sql of select * from $tbl_name where id=[$post=items]; Then i need to use the $get to put all the items in the form below:
<form id="form1" name="form1" method="post" action="">
<table width="100%" border="0" cellspacing="4" cellpadding="4">
<tr>
<td width="20%">Water Purveyor
<input name="water-purveyor" type="text" id="water-purveyor" size="35" />
</td>
<td colspan="2">Facility Contact
<input type="text" name="facility-contact" id="facility-contact" /></td>
<td colspan="2">Facility Address
<input type="text" name="facility-address" id="facility-address" /></td>
</tr>
<tr>
<td>Manufacturer
<input type="text" name="manufacturer" id="manufacturer" /></td>
<td width="20%">State
<select name="state" id="state">
</select></td>
<td width="20%">Model #
<input name="model-num" type="text" id="model-num" size="10" /></td>
<td width="20%">Serial #
<input name="serial-num" type="text" id="serial-num" size="10" /></td>
<td width="20%">Meter #
<input name="meter-num" type="text" id="meter-num" size="10" /></td>
</tr>
<tr>
<td>Owner
<input type="text" name="owner" id="owner" /></td>
<td>Phone #
<input name="phone-num" type="text" id="phone-num" size="12" /></td>
<td>Caged
<input type="checkbox" name="caged" id="caged" /></td>
<td>Locked
<input type="checkbox" name="locked" id="locked" /></td>
<td>Code key
<input name="code-key" type="text" id="code-key" size="6" /></td>
</tr>
<tr>
<td colspan="2">Owner Address
<input name="owner-address" type="text" id="owner-address" size="50" /></td>
<td>Owner City
<input type="text" name="owner-city" id="owner-city" /></td>
<td>Owner State
<select name="owner-state" id="owner-state">
</select></td>
<td>Owner Zip
<input name="owner-zip" type="text" id="owner-zip" size="10" /></td>
</tr>
<tr>
<td>Contact
<input type="text" name="contact" id="contact" /></td>
<td>Contact Phone
<input name="contact-phone" type="text" id="contact-phone" size="10" /></td>
<td> </td>
<td>Other</td>
<td> </td>
</tr>
<tr>
<td colspan="2">Facility Name
<input name="facility-name" type="text" id="facility-name" size="40" /></td>
<td colspan="3">Assembly Address
<input name="assembly-address" type="text" id="assembly-address" size="75" /></td>
</tr>
<tr>
<td colspan="5">Onsite Location
<input name="onsite-location" type="text" id="onsite-location" size="75" /></td>
</tr>
<tr>
<td colspan="5">email Address
<input name="email" type="text" id="email" size="125" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>SHUTOFF VALVES</td>
<td colspan="2"><table width="100%" border="0" cellspacing="4" cellpadding="4">
<tr>
<td>N/A</td>
<td>Good</td>
<td>Poor</td>
<td>Fail</td>
</tr>
</table></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Valve 1</td>
<td colspan="2"><table width="100%" border="0" cellspacing="4" cellpadding="4">
<tr>
<td><input type="checkbox" name="v1-na" id="v1-na" /></td>
<td><input type="checkbox" name="v1-good" id="v1-good" /></td>
<td><input type="checkbox" name="v1-poor" id="v1-poor" /></td>
<td><input type="checkbox" name="v1-fail" id="v1-fail" /></td>
</tr>
</table></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Valve 2</td>
<td colspan="2"><table width="100%" border="0" cellspacing="4" cellpadding="4">
<tr>
<td><input type="checkbox" name="v2-na" id="v2-na" /></td>
<td><input type="checkbox" name="v2-good" id="v2-good" /></td>
<td><input type="checkbox" name="v2-poor" id="v2-poor" /></td>
<td><input type="checkbox" name="v2-fail" id="v2-fail" /></td>
</tr>
</table></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Assembly Replacement?
<input type="checkbox" name="assembly-replacement" id="assembly-replacement" /></td>
<td>if yes Serial #
<input type="text" name="assembly-replacement-serial" id="assembly-replacement-serial" /></td>
<td>New Installation
<input type="checkbox" name="new-install" id="new-install" /></td>
<td>Permit #
<input type="text" name="permit-num" id="permit-num" /></td>
<td> </td>
</tr>
<tr>
<td>Containment
<input type="checkbox" name="containment" id="containment" /></td>
<td>Isolation
<input type="checkbox" name="isolation" id="isolation" /></td>
<td colspan="2">Assembly Ground Clearance
<input type="text" name="assembly-ground-clearance" id="assembly-ground-clearance" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Domestic
<input type="checkbox" name="domestic" id="domestic" /></td>
<td>Irrigation
<input type="checkbox" name="irrigation" id="irrigation" /></td>
<td>Fire Line
<input type="checkbox" name="fire-line" id="fire-line" /></td>
<td>Alarmed Fire Line
<input type="checkbox" name="alarmed-fire-line" id="alarmed-fire-line" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><strong><em><u>Double Check Balve Assembly Repair</u></em></strong></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Repairs</td>
<td>Check Valve 1</td>
<td> </td>
<td>Check Valve 2</td>
<td> </td>
</tr>
<tr>
<td rowspan="3"> </td>
<td>Cleaned
<input type="checkbox" name="cv1-repair-cleaned" id="cv1-repair-cleaned" /></td>
<td> </td>
<td>Cleaned
<input type="checkbox" name="cv2-repair-cleaned" id="cv2-repair-cleaned" /></td>
<td> </td>
</tr>
<tr>
<td><strong>Replaced</strong></td>
<td> </td>
<td><strong>Replaced</strong></td>
<td> </td>
</tr>
<tr>
<td>Rubber Kit
<input type="checkbox" name="cv1-rubber-kit" id="cv1-rubber-kit" /></td>
<td> </td>
<td>Rubber Kit
<input type="checkbox" name="cv2-rubber-kit" id="cv2-rubber-kit" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Other
<input type="checkbox" name="cv1-other" id="cv1-other" /></td>
<td> </td>
<td>Other
<input type="checkbox" name="cv2-other" id="cv2-other" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2">Comments
<textarea name="cv1-other-comments" id="cv1-other-comments" cols="45" rows="5"></textarea></td>
<td colspan="2">Comments
<textarea name="cv2-other-comments" id="cv2-other-comments" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2">Initial Test By
<input name="initial-test-by" type="text" id="initial-test-by" size="50" /></td>
<td colspan="2">Certified Tester #
<input type="text" name="certified-tester-num" id="certified-tester-num" /></td>
<td>Test Date/Time
<input type="text" name="test-date-time" id="test-date-time" /></td>
</tr>
<tr>
<td>Pass
<input type="checkbox" name="initial-test-pas" id="initial-test-pas" /></td>
<td>Fail
<input type="checkbox" name="initial-test-fail" id="initial-test-fail" /></td>
<td colspan="2">Calib Expire Date
<input type="text" name="calib-expire-date" id="calib-expire-date" /></td>
<td>Guage Serial #
<input type="text" name="gague-serial-num" id="gague-serial-num" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2">Repair Test By
<input name="repair-test-by" type="text" id="repair-test-by" size="50" /></td>
<td colspan="2">Repair Date/Time
<input type="text" name="repair-date-time" id="repair-date-time" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2">Final Test by
<input name="final-test-by" type="text" id="final-test-by" size="50" /></td>
<td colspan="2">Certified Tester #
<input type="text" name="ft-certified-tester-num" id="ft-certified-tester-num" /></td>
<td>Test Date/Time
<input type="text" name="ft-date-time" id="ft-date-time" /></td>
</tr>
<tr>
<td>Pass
<input type="checkbox" name="ft-pass" id="ft-pass" /></td>
<td>Fail
<input type="checkbox" name="ft-fail" id="ft-fail" /></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="5">Comments
<textarea name="comments" id="comments" cols="80" rows="5"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2">Video upload <input type="file" name="uploadvideo" /></td>
<td colspan="2">Image 1 <input type="file" name="uploadimage" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2">Image 2 <input type="file" name="uploadimage2" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2">Image 3 <input type="file" name="uploadimage3" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2">Image 4 <input type="file" name="uploadimage4" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2">Image 5 <input type="file" name="uploadimage5" /></td>
<td> </td>
</tr>
</table>
</form>
you can use jquery when to get the selected value like this
$("#dropdownid").change(function({ var vals = $(this).val(); })
then when you are redirecting to next page then add it as get parameter
(report.php)
if(isset($_REQUEST['submit'])){
$option = $_POST['items'];
mysql_query("SELECT * FROM `table_name` WHERE FIELD_NAME = '$options'");
}
if(isset($_REQUEST['submit'])){
$option = $_REQUEST['items'];
mysql_query("SELECT * FROM `table_name` WHERE FIELD_NAME = '$options'");
}
You can pass value to next page using php session.
$_SESSION ['name'] = $value;
and you can get value using php session from next page.
$value = $_SESSION ['name'];
I have a webpage where I ask input from the user and when he clicks the add button, it should insert the input from the user into the database. I always thought that you couldn't use POST and GET at the same time but according to this and this answers it should be possible. Yet, I can't seem to get their solutions working.
The script inserts something in the db (an id is generated) but the seriesName field remains empty.
The PHP script:
<?php
$con=mysqli_connect("localhost","user","passwd","database");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$issueSeries = mysqli_real_escape_string($con, $_GET['addSeries']);
mysqli_query($con,"INSERT INTO series (seriesName) VALUES ('$issueSeries')");
mysqli_close($con);
?>
The HTML:
<div id="issueAddInformationLayout">
<div id="issueAddCredits">
<form action="addIssue.php" method="post">
<table>
<tr id="lblAddCreator">
<td><p>NR</p></td>
<td><p>Series</p></td>
<td><p>Volume</p></td>
<td><p>Title</p></td>
<td><p>Publisher</p></td>
</tr>
<tr>
<td><input type="text" id="addNR" size="3%"/></td>
<td><input type="text" id="addSeries" size="25%" /></td>
<td><input type="text" id="addVolume" size="25%" /></td>
<td><input type="text" id="addTitle" size="30%" /></td>
<td><input type="text" id="addPublisher" size="30%" /></td>
</tr>
</table>
<table>
<tr id="lblAddCreator">
<td><p>Writer</p></td>
<td></td>
<td></td>
</tr>
<tr id="txtAddCreator">
<td><input type="text" id="addWriter1" size="30%" /></td>
<td><input type="text" id="addWriter2" size="30%" /></td>
<td><input type="text" id="addWriter3" size="30%"/></td>
<td><input type="text" id="addWriter4" size="30%"/></td>
</tr>
<tr id="lblAddCreator">
<td><p>Editor</p></td>
<td></td>
<td></td>
</tr>
<tr id="txtAddEditor">
<td><input type="text" id="addEditor1" size="30%" /></td>
<td><input type="text" id="addEditor2" size="30%"/></td>
<td><input type="text" id="addEditor3" size="30%"/></td>
<td><input type="text" id="addEditor4" size="30%"/></td>
</tr>
<tr id="lblAddCreator">
<td><p>Letterer</p></td>
<td></td>
<td></td>
</tr>
<tr id="txtAddLetterer">
<td><input type="text" id="addLetterer1" size="30%"/></td>
<td><input type="text" id="addLetterer2" size="30%"/></td>
<td><input type="text" id="addLetterer3" size="30%"/></td>
<td><input type="text" id="addLetterer4" size="30%"/></td>
</tr>
<tr id="lblAddCreator">
<td><p>Colourist</p></td>
<td></td>
<td></td>
</tr>
<tr id="txtAddColourist">
<td><input type="text" id="addColourist1" size="30%"/></td>
<td><input type="text" id="addColourist2" size="30%"/></td>
<td><input type="text" id="addColourist3" size="30%"/></td>
<td><input type="text" id="addColourist4" size="30%"/></td>
</tr>
<tr id="lblAddCreator">
<td><p>Cover Artist</p></td>
<td></td>
<td></td>
</tr>
<tr id="txtAddCoverArtist">
<td><input type="text" id="addCoverArtist1" size="30%"/></td>
<td><input type="text" id="addCoverArtist2" size="30%"/></td>
<td><input type="text" id="addCoverArtist3" size="30%"/></td>
<td><input type="text" id="addCoverArtist4" size="30%"/></td>
</tr>
<tr id="lblAddCreator">
<td><p>Inker</p></td>
<td></td>
<td></td>
</tr>
<tr id="txtAddInker">
<td><input type="text" id="addInker1" size="30%"/></td>
<td><input type="text" id="addInker2" size="30%"/></td>
<td><input type="text" id="addInker3" size="30%"/></td>
<td><input type="text" id="addInker4" size="30%"/></td>
</tr>
<tr id="lblAddCreator">
<td><p>Penciler</p></td>
<td></td>
<td></td>
</tr>
<tr id="txtAddPenciler">
<td><input type="text" id="addPenciler1" size="30%"/></td>
<td><input type="text" id="addPenciler2" size="30%"/></td>
<td><input type="text" id="addPenciler3" size="30%"/></td>
<td><input type="text" id="addPenciler4" size="30%"/></td>
</tr>
<tr id="lblAddCreator">
<td><p>Trade Paper Back</p></td>
<td><p id="lblAddCover">Cover</p></td>
</tr>
</table>
<table>
<tr id="txtAddTPB">
<td><input type="text" id="addTPB" size="30%"/></td>
<td>
<p id="btnAddCover" enctype="multipart/form-data" action="parse_file.php" method="post">
<input type="file" name="uploaded_file">
</p>
</td>
<td>
<id="btnAddIssue"><input type="submit" value="Add">
</td>
</tr>
</table>
</form>
</div>
</div>
There seemed to be some confusion about the HTML so I added the full HTML code. Keep in mind: this is purely for myself and I don't really care about stuff like that tables are outdated :)
In HTTP, you can't use GET and POST at the same time but you can make a POST request which has a query string as part of the URL.
PHP will populate $_POST with the body of the request and $_GET with the query string, even if the request was a POST request.
Since the form is POST, the data from the inputs will be put into the body and not the query string (so will appear in $_POST not $_GET).
If the value of addSeries was fixed then you could use it with $_GET like so:
<form id="btnAddIssue" action="addIssue.php?addSeries=someValue" method="post">
… but since you are taking user input, use $_POST to read the value after you put the input inside the form.
Your input is outside of your form so it isn't submitted.
<form id="btnAddIssue" action="addIssue.php" method="post">
<input type="text" id="addSeries" size="25%" />
<input type="submit" value="Add">
</form>
You then need to change $_GET['addSeries'] to $_POST['addSeries'] since your form is set to POST (or change your form to submit via GET).
Your input is outside the form tag which won't be considered when user submits the form.
<form id="btnAddIssue" action="addIssue.php" method="post">
<input type="text" id="addSeries" size="25%" />
<input type="submit" value="Add">
</form>
And since you are making a post request onto php side it would be $_POST to reference that input's value
Also, sometimes it would be good to make use of $_REQUEST which contains data from both GET and POST so you have proper data from request everytime
$issueSeries = mysqli_real_escape_string($con, $_REQUEST['addSeries']);
Your text filed is placed outside the form and so no value (of that text filed) will be submitted to the action page.
Change it to
<form id="btnAddIssue" action="addIssue.php" method="post">
<input type="text" id="addSeries" size="25%" />
<input type="submit" value="Add">
</form>
Also use $_POST, or you can even use $_REQUEST (you can use $_REQUEST for both get and post variables)
I new to programming, and have just finished the jquery course on CodeAcademy.I'm currently trying to create a chained select using Jquery's AJAX function to call a php page which runs a query on my database and echoes it out to my main html page.
Currently, I am able to load only my first , the second and third selects do not seem to be working, and i do not know what exactly it is that i'm doing wrong.
Jquery Code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#category").load("AddItemCat.php");
});
$("#category").onchange(function(){
var category=$("#category").val();
$("#subcat").load("AddItemSubCat.php?category="+category);
});
$("#subcat").onchange(function(){
var category=$("#category").val();
var subcat=$("#subcat").val();
$("#subcat").load("AddItemSubCat.php?category="+category+"&subcat="+subcat);
});
My HTML Form:
<form action="<?PHP echo $_SERVER['PHP_SELF'] ?>" name="edititem" enctype="multipart/form-data" method="POST">
<table border='1'>
<tr>
<td colspan="3">
Category:
<select name="category" id="category" ></select>
SubCategory:
<select id="subcat" name="subcat"></select>
Item:
<select id="item" name="item"></select>
</td>
</tr>
<tr>
<td>Item Name</td>
<td><input type="text" name="itemname" size="30" maxlength="50" required="required"></td>
</tr>
<tr>
<td>Item Price</td>
<td><input type="number" name="itemprice" size="30" min="1" required="required"></td>
</tr>
<tr>
<td>Item Info</td>
<td><textarea name="iteminfo" col="40" rows="10" maxlength="300" required="required"></textarea>
</tr>
<tr>
<td>Filename:</td>
<td><input type="file" name="upload[]" /></td>
</tr>
<tr>
<td>Filename:</td>
<td><input type="file" name="upload[]" /></td>
</tr>
<tr>
<td>Filename:</td>
<td><input type="file" name="upload[]" /></td>
</tr>
<tr>
<td>Filename:</td>
<td><input type="file" name="upload[]" /></td>
</tr>
<tr>
<td>Filename:</td>
<td><input type="file" name="upload[]" /></td>
</tr>
<tr>
<td colspan="2"><input type="SUBMIT" name="Button" value="Submit"></td>
</tr>
<tr>
<td colspan="2"><?PHP if(isset($errormsg)){echo"$errormsg";}?></td>
</tr>
<tr>
<td colspan="3"><font color="#FF0000"></font></td>
</tr>
I would really appreciate it if someone could point out my mistake and give me pointers on rectifying it.Thanks!
Way to much code to help you but since you say that the jQuery part does not work:
$("#category").onchange(function(){
This should be
("#category").on("change", function(){
There is no onchange in jQuery 1.10 (or any other version?). A brief look into the console would have shown you the error I guess. Additionally, you shoud put all your other calls inside $(document).ready as well.
try use page url instead of file name. e.g - url to AddItemSubCat.php
I wonder whether someone may be able to help me please.
I've put together a form and php code (below) that allows an administrator to search for member records from a mysql database using the email address as the search criteria.
HTML Form
<form name="memberpasswordresetform" id="memberpasswordresetform" method="post" action="search.php">
<div class="container">
<p align="justify">Member Details </p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="26%" height="25"><strong>Email Address </strong></td>
<td width="4%"> </td>
<td width="70%"><input name="email" type="email" id="email" size="50" /></td>
</tr>
<tr>
<td height="25"><strong>Confirm Email Address </strong></td>
<td> </td>
<td><input name="conf_email" type="email" id="conf_email" size="50" /></td>
</tr>
<tr>
<td height="25"><label>
<input type="submit" name="Submit" value="search" />
</label></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>First Name </strong></td>
<td> </td>
<td><input name="fname" type="text" id="fname" size="30" /></td>
</tr>
<tr>
<td height="25"><strong>Last Name </strong></td>
<td> </td>
<td><input name="lname" type="text" id="lname" size="30" /></td>
</tr>
<tr>
<td height="25"> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>New Password</strong></td>
<td> </td>
<td><input name="newpass" type="password" id="newpass" size="30" /></td>
</tr>
<tr>
<td height="25"><strong>Confirm New Password </strong></td>
<td> </td>
<td><input name="conf_newpass" type="password" id="conf_newpass" size="30" /></td>
</tr>
<tr>
<td height="25"><input type="submit" name="save" value="save" /></td>
<td> </td>
<td> </td>
</tr>
</table>
</div>
</form>
PHP Script
<?php
include("admin/link.php");
include("admin/opendb.php");
mysql_select_db ("userdetails");
$term = $_POST['email'];
$sql = mysql_query("select forename, surname, email address from userdetails where emailaddress like '%$email%'");
while ($row = mysql_fetch_array($sql)){
echo '<br/> First Name: '.$row['forename'];
echo '<br/> Last Name: '.$row['surname'];
echo '<br/><br/>';
}
?>
The search functionality works fine, but I can't work out how to populate the forename and surname fields on my form from the records retrieved from my database. I've been looking for, and found examples on how to do this, if I want to simply show the data as a table, but I can't find any that explain how to populate the fields in a form.
I just wondered whether it would be at all possible that someone could provide some guidance please on how I can do this.
Many thanks
The previous answer will work fine if short tags are enabled on the server. You should stick to the long syntax as below in case you change hosting providers at a later date.
<input name="fname" type="text" id="fname" size="30" value="<?php echo $row['surname']; ?>" />
just set the value of your input element
<tr>
<td height="25"><strong>First Name </strong></td>
<td> </td>
<td><input name="fname" type="text" id="fname" size="30" value="<?= $row['surname'] ?>" /></td>
</tr>