Home › Forums › Quform WordPress › PHP in HTML Field in Form
- This topic has 6 replies, 2 voices, and was last updated 11 years, 5 months ago by lawrencepepper.
- AuthorPosts
- June 5, 2013 at 2:40 pm #4700lawrencepepperParticipant
I am trying to use PHP in a form.
I have an update form that populates with default values that are being generated from a query.
One of the fields in my form is a File Upload field.
Since there is not a way to show a dynamic default value for the file upload field I want to display the name of the current file that is in the database. I am using an HTML field and have placed the following code in it to display the name of the file that is stored in my database:
<? echo "Current File: " . $row['file']; ?>
But nothing shows. There is a query on the page that this form is on that gets the data from my database.
This is the code form the page:
<?php
$rnumber = $_SESSION['iphorm_10']['iphorm_10_3'];
echo "<h4>Part Number: " . $rnumber . "</h4>";
$con = mysql_connect("localhost","xxx","xxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}mysql_select_db("edata", $con);
$result = mysql_query("SELECT * FROM part_record WHERE record_number = '$rnumber'");?>
<?php
if (mysql_num_rows($result)==0) {
echo "[warning_box]The part number " . $rnumber . " does not exist. Please try again.[/warning_box]
";}
else {
while($row = mysql_fetch_assoc($result)) {?>[iphorm id=9 name="Update Part" values="current_description=<? echo $row['description']; ?>&current_detailed=<? echo $row['detailed_description']; ?>&current_notes=<? echo $row['notes']; ?>&current_rnumber=<? echo $rnumber; ?>&current_manufacturer=<? echo $row['manufacturer']; ?>&current_mnumber=<? echo $row['manufacturer_number']; ?>&current_altmanufacturer=<? echo $row['alt_manufacturer']; ?>&current_altnumber=<? echo $row['alt_number']; ?>&current_file=<? echo $row['file']; ?>&current_file_description=<? echo $row['file_description']; ?>"]
<?php
}}?>
June 5, 2013 at 5:58 pm #4705AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
June 5, 2013 at 6:01 pm #4706lawrencepepperParticipantI am not saving the filename here, I am looking it up from the database and trying to display it.
L
June 5, 2013 at 6:07 pm #4707AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
June 5, 2013 at 6:22 pm #4709lawrencepepperParticipantOK,
Thanks.
Can I suggest that in a future release the ability to place PHP in the HTML element be added.
L
June 6, 2013 at 11:10 am #4743AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
June 6, 2013 at 3:23 pm #4751lawrencepepperParticipantAlly,
Thanks! That worked.
Great idea!
L
- AuthorPosts
- You must be logged in to reply to this topic.