How To Create A Hidden Field Variable From An Echoed PHP Figure?
I have a PHP script on a shopping cart summary page that creates an invoice number and then echoes it to the page. This page, when submitted, will go to the shopping cart processor.
The echo portion of the script is working properly, it generates the number as intended.
My problem is that, not being very experienced in PHP, I want the invoice number not only echoed (which it is doing properly now), but also to populate a value in a hidden field that is submitted to the shopping cart processing page. My question is how do I populate the hidden field with the figure that is now being echoed in the script below?
The script that generates and echoes the invoice number is as follows:
<?php
echo "SA"; //department code
echo date ("mdy"); //date generator
// begin counter this reads figure from "count_file.txt"
if (file_exists('count_file.txt'))
{
$fil = fopen('count_file.txt', r);
$dat = fread($fil, filesize('count_file.txt'));
echo $dat+1;
fclose($fil);
$fil = fopen('count_file.txt', w);
fwrite($fil, $dat+1);
}
else
{
$fil = fopen('count_file.txt', w);
fwrite($fil, 1);
echo Ƈ'
fclose($fil);
}
// end counter
?>
The hidden field is as follows:
<input name="Invoice_Num" type="hidden" id="Invoice_Num" value=" ">
I would like the value in the above to reflect the invoice number that is echoed by the above PHP script.
View Complete Forum Thread with Replies
Related Forum Messages:
Create A Hidden Field Which Contains Some Sort Of Unquie Data
I have a page with a form, and I handle it in the same page. I submit some text and it is displayed. The problem is I want it to be displayed just after I click submit. I'm trying to put a header(link to same page) after the user submit, but it is not working. I can only view the message when I submit, and manually refresh the page on the browser menubar.
View Replies !
How To Pass Variable To Another Page Into A Hidden Field In The Form.
I have a script to tell whether a domain name is available or not. The code redirects to the php script and displays the results in a template file called "whois.html". Then on the page that displays the results, I want to have a link to go to the next page. I want to pass the variable that contains the selected domain name called $domain.$ext. I need to know how to pass that variable to another page into a hidden field in the form.
View Replies !
Variable In A Php Echoed Form
At the moment it prints " /> and I lose the variable. <?php echo '<form action="formt.php" method="post"> <input type="hidden" name="uname" value="$_SESSION["username"]" /> <input type="submit" label="submit"></form>' ?>
View Replies !
Set The Value Of A Hidden Field?
is it possible to dynamically set the value of a hidden field on a button? I guess via Javascript? I was passing a prodID value on an image, which worked great in firefox, but then I found out in IE this doesnt work Its fine with a submit button+ value, but this looks ropey and not really what I am after! Im basically trying to prevent having multiple forms with hidden ID's and just 1 form with the ID being set on the BUY ITEM button. Code:
View Replies !
Hidden Field
I have a textfield in a form and the name of the textfield is textfieldName4. If I type 'myroadname' in the textfield everything works fine. But if I type 'myroadname 2A' I only get 'myroadname' left when I recieve the value on the other page. Everything after the space seems to just dissapear. Here is the code that I use for sending the hidden field. PHP Code: echo'<input type="hidden" name="value5" value='.$_POST['textfieldName4'].'>'
View Replies !
Two Dimension Hidden Field
Is there a way to get a two dimension hidden field? One dimension <input name = "test[]" type = "hidden"> Is there such thing as <input name = "test[1][]" type = "hidden">
View Replies !
Hidden Field In Header
when this script executes i really need the number of uploads to go with the header so i know how many upload sections to input: if(($uploadsneeded) > 1) { $uploadsneeded = $_POST['uploadsneeded']; header("Location: uploadmultiplefiles.php"); } the range is from 1-5 and is stored in: $_POST['uploadsneeded']; is there away to carry this value onto the uploadmultiplefiles.php page?
View Replies !
Variables In Hidden Field
i am trying to get the script working. it first gets the variables pid and version either from a POST or GET. these variables should be sent to the next page using the hidden input fields. the problem is that there is nothing coming out at the other end (test_postget.php).wht should i supoose to do?
View Replies !
Form Field Hidden
why can I pass value of my userid(key) as a hidden field in the html form. I put it in a variable and use GET in form instead of POST, I can see that value in the address bar. However if I use POST that variable is empty and as such I can run MySQL statement because value of that variable is used in WHERE statement. Even I put that variable as one of the regular form fields it is still not being passed on to the following pages.
View Replies !
Listbox In Hidden Field
PHP Code: <form action="update_orders.php" method="post">     Username: <?php echo $row['username']; ?><br>     Order ID: <?php echo $row['orderid']; ?><br> <input type="hidden" name="orderid"              value="<?php echo $_POST['orderid']; ?>">     Total: <?php echo $row['total']; ?><br>     Order Date: <?php echo $row['order_date']; ?><br>     Order Status: <select name="Pending" size="1">                   <option value="Sent"> Sent                   <option value="Processing" selected="selected"> Pending                   </select><br> .........
View Replies !
How To Hide 'hidden' Form Field?
I am sending the user's password in form's hidden field as Code: <input type=hidden name="studen_pass" value="readfromdatabase"> but i dont want anyone to read it via watching its source code. is there any trick to hide it with php so that no one can read the password hidden field value by watching page's source code.
View Replies !
$_GET Won't Read My Hidden Field
I am trying to include a dynamically changeable file in my website with PHP and Javascript so I am using a hidden field to hold the name of the file I want to include, and I am using the$_GET function to read the hidden field, but it says the field has no value even though I have a default value in the field. So my question is how do I get PHP to read the value of a hidden field?
View Replies !
Dynamic Hidden Field Empty?
I am having a weird error. It says that "Column 'img_1' can not be NULL". Which is weird because my input says <input type="hidden" name="img_1" value="<?php echo $imgfilenameout; ?>" /> When I output the variable just on the page it outputs correctly. So I don't understand why it would not output in the hidden field so I can upload it to the database.
View Replies !
Odd Problem: Data From Hidden Field Is Not Sent To Server...
Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one firstname/lastname/telephone box - when the user clicks the add button, I read the values from the form fields and record them into a hidden text input field. This part works because during debugging, I have converted the <input type=hidden> into a <input type=text> to visably confirm my data is being copied into the 'hidden' field. Once the user has entered in one or more names, they can click another button and submit the form for processing. My idea is that I would then parse this hidden field server side... I have a WAMPHP based server and as a test, I dump out my entire $_POST (basically, the name and value in every INPUT tag). My PHP script picks up the name of every input tag, including the hidden field (like it should) but for some reason, the value that was written to the hidden field is not passed to the server. Thus, for the PHP folk reading this post, my hidden input field is called mylist and $_POST['mylist'] exists, but its empty. Even though before processing, I could visably see the input in the box (for debugging remember, I made the input tag box a normal, unhidden one). Here is what I have done to try and resolve: - I have used both Mozilla 1.7.5 and IE6 - both provide same results - my hidden field name gets passed, but not its value. - I have created another hidden field and given it a default value ie I have <input type="hidden" name="extraone" value="xyz"> and I get $_POST['extraone']="xyz" passed to my php server, like I would expect - however, the value of mylist is sent empty, even though it has data. - I have even put in a javascript alert box just before the form is sent to the server and can see the result in my (unhidden) box, and the same value displayed in the javascript alert - but again, the value of the mylist does not get sent to the server. The only difference is that my hidden field (even if its displayed like an ordinary text input box) does not post data written to form fields as the result of a javascript function. Interestingly though, the server does know about the input tag box since it does receive $_POST['mylist'], it justs receives it empty. What gives? If the form reads my input from one field, and writes it to another field, then it should be sent to the server, true? Also... my tags are all inside my <form></form> tag (which is proven by double checking, and the fact that I do get the input tag box name sent to my server). Since I can see the data values in the box, it tells me my javascript is doing what it should be doing - so I don't see any point in including my javascript (though I have no problems doing so if someone requests it). On the php server, I am using a simple phpinfo(); to check the data is being received...
View Replies !
Adding Two Variables And Assigning To A Hidden Field
Title says it all. I have a hidden feild and would like to assign it a integer based of two numbers from different recordsets here is my code for what i tried <input type="hidden" name="player1_attack" value="<?php $row_player1['attack'] + $row_player1_character['attack']; ?>"/>
View Replies !
Hidden Input Field Inside A Select?
I need to get a field from the database and attach it with the loop that is created around the <select> options, however doing a hidden field won't work, as it isn't detected when in a <select> Code:
View Replies !
Passing HTML In Hidden Input Field
I just wanted to take a poll to see what the best way to pass a chunk of text containing HTML in a hidden input form element would be. I'm trying to pass the text from one page to another to another in a content management scenario, but the whole thing breaks down when HTML enters the picture. On the page where the value is pulled from the database into a textbox, I'm using: <? <textarea cols="45" rows="10" name="blurb">".$blurb."</textarea> ?> On the next page, the user can review the code displayed as plain text using: <? echo(nl2br($blurb)); ?> There are no problems so far. But at the bottom of that page in the form that will pass the variables on to the script that will write the final changes to the database, everything falls apart when HTML comes into play. <input type="Hidden" name="blurb" id="blurb" value="<? echo $blurb; ?>"> This line made everything fall apart when I put an anchor tag into the text. The closing > made it think the tag itself had closed, and the link text started printing to the screen. So, what's the best way to handle situations like this. Would I use htmlentities() to get it to the database writing script and the use html_entity_decode() when actually passing the values into the db? Or is there a more sublime solution?
View Replies !
Multidimensional Arrays - Adds The ID As A Hidden Field
i have a form for a php/mysql based online test. at present the code calls the questions and their unique ID's and puts the questions in a table and adds the ID as a hidden field. the problem that i am having is that im not sure how i am going to put the answers back in the DB. i cant just use the POST method because there may be hundreds of entry's so i was thinking of using 2 arrays, 1 for ID's and 1 for questions. ie. the first entry in ID_array will match the first entry in QUESTION_array. this would work fine but for some questions there can be more than one possible answer. do you think that multidimensional arrays may be the way to go? if so how would you suggest i implement this?
View Replies !
How To Refer From One Variable To Hidden Variable?
I have started with my php source code shown below, and how can I refer from one var to hidden var? ---------------------------------------------------------------------------- if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO users (UserID, UserName, Password) VALUES (%s, %s, %s)", GetSQLValueString($_POST['UserID'], "int"), GetSQLValueString($_POST['UserName'], "text"), GetSQLValueString($_POST['Password'], "text")); mysql_select_db($database_SHHConnection, $SHHConnection); $Result1 = mysql_query($insertSQL, $SHHConnection) or die(mysql_error()); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO holidaymaker (HMID, Name, Status) VALUES (%s, %s, %s)", GetSQLValueString($_POST['HMID'], "int"), GetSQLValueString($_POST['Name'], "text"), GetSQLValueString($_POST['Status'], "text")); mysql_select_db($database_SHHConnection, $SHHConnection); $Result1 = mysql_query($insertSQL, $SHHConnection) or die(mysql_error()); } <input type="hidden" name="UserID" value=""> <input type="hidden" name="HMID" value= ""> ---------------------------------------------------------------------------- The "UserID" is generated by MySql with auto_increment.[color=blue] >UserID int(4) auto_increment primary key,[/color] Assume that I want to add new user and the value for UserID is 5 (after auto increment). Then, I want HMID refer to UserID, the value of HMID is also 5, thats mean HMID = UserID, how can I do that? What is the command?
View Replies !
Passing A Hidden Variable
Is there anyway to pass a hidden variable, as in a form, with urls, without having to add massive lines of code to my pages? I basically want each page to check for a variable, and if not found, default to 1. if the user clicks on the other setting, then the variable is passed as 2 on all the subsequent pages (and if clicking on the original setting from there.. continue through with 1 as the variable). I've checked out a few options already, but none worked out. i don't want to use sessions or cookies. $_GET seemed like the answer, but i don't see how to pass it.
View Replies !
Determining Whether Or Not A Form Variable Is Hidden
Is there any way to dynamically determine whether or not a variable comes from a hidden field within a separate form file? Basically, I have an HTML file with an e-mail form in it and I want to be able to use a completely separate, generic PHP file to parse the information and determine how many fields are to be filled in by the user and how many were created by the designer of the form for future reference.
View Replies !
HTML - Hidden Variable Within A Form
I have a problem making PHP work to its full. i have installed php 5.x version, apache 1.3.x ver and mysql 3.x version all of them are working fine. i have a problem.... when i pass any hidden variable within a form like in the code below Code:
View Replies !
Passing The Server Date Through A Hidden Variable
What I want to do this time is pass the date on the server from a form to the database. Basically I have a parts request form that is sorted by date, but I don't want to leave entering the date to the user. I would like to have my page pass the date as a hidden variable from the form and insert it into the database. I have included the form below. Thanks in advance for your assistance. I'm hoping that someday I can return the favor.
View Replies !
Passing Variable Through Hidden Input Drops Data
I have a form that is filled out that is passed to a preview page so the user can validate the changes they're making. On the preview page, they review their changes and hit the "Submit" button to have the data changed in the database. The preview page submits the data to the page that does the work using hidden inputs like: PHP Code:
View Replies !
Loop Through Array And Create Variable Session Variable Names
As part of my user authentication class I've written a method that sets session variables. I pass an array to the function by reference which contains elements populated with information from the users table in the DB (name, street, country etc) At the moment the function looks like this: /* Set the session variables for easy access to user data */ function _setSessionData(&$userData) { $_SESSION['loggedOn'] = true; // Logged on $_SESSION['userID'] = $userData['UserID']; $_SESSION['username'] = $userData['UserName']; $_SESSION['password'] = $userData['Password']; $_SESSION['firstName'] = $userData['FirstName']; $_SESSION['surname'] = $userData['Surname']; $_SESSION['email'] = $userData['Email']; $_SESSION['street'] = $userData['Street']; $_SESSION['city'] = $userData['City']; return true; } What I'm wondering is if it is possible to loop through the $userData array, and dynamically name and populate the session variables rather than listing them all and assigning like I have?
View Replies !
Being Echoed
I have following html before head of html in my page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head>
View Replies !
Opinion On Database Field Create
i would like save three values into members table. "win, lost and draw" for example. now the question comes like this. which ways you think is the better or you could suggest a more efficient way of doing that. Code:
View Replies !
HTML Echoed Out
Does anyone have any idea why when I echo HTML it doesn't parse the HTML but outputs the code? I even added two <h2> tags manually and it works, so it's just from pulling it out of the database. PHP Code: <?php //The <h2>s work fine but the array variable being outputted doesn't parse the HTML echo "<h2>".$profile['biography']."</h2>"; ?>
View Replies !
HTML Echoed
I have the notion that everything is more secure if everything is in php, and nothing is in html. Perhaps I am mistaken in my understanding. But, because I believe that everything would be more secure in php, I am trying to take an html form, and find a way to ECHO it in php. It is an example form that I found in google. It works just fine as HTML, and it is a submit to a php script which will receive the data through $POST. But, I am trying to build all the HTML in $form and then echo it. I am not having much success. Code:
View Replies !
Create A Date Field Of Type TIMESTAMP
I have a guestbook on my site. It uses a mysql database and holds names, email and a message. I'm trying to modify it so that it will also hold the date/time that reecord was submitted. So I want and created a date field of type TIMESTAMP to hold these values, and adjusted my php script to add another field. Now, when the guestbook is filled out, in my new field, all I get is a bunch of 0s. Why is this?
View Replies !
Create A Form That Validates At Least 1 Field Has Data?
How can i create a form that validates that at least 1 field has data? for instance, right now i have that you have to at least search by "last name", but i want to be able to say that "you must enter data into at least one search criterion" and have the form validate that at least one, doesnt matter which field...has data entered into the field... Code:
View Replies !
Formating Echoed Table
How would I format the table with borders backgrounds etc. printf("<table>"); do { $myrow = pg_fetch_row($result_set,$rows); printf("<tr>"); for ($i=0; $i < $count_ch; $i++) { printf("<td>"); printf($myrow[$i]); printf("</td>"); } printf("</tr>"); $rows++; } while($rows < $rowsnum); }
View Replies !
Last Twelve Hours Echoed
I am so tried but can someone help and show me a basic way to only display the last twelve hours of results from the MySQL? I have a column with the time, how do I only show the last tweleve hours?
View Replies !
Echoed The MySQL Query
I'm currently building a time booking system, and what I have done is created a few tables in my database and populated these with some test data. The problem I'm having is that I know for a fact that when I click on the 1st Sept for example the first couple of time slots have been taken,so for a test I've used the word 'booked', this works, if the time slot is not taken then it should say 'available', this doesn't do it. I have echoed the MySQL query and I've test this on the MySQL console and it works, but yet it says 'booked' when its really not.
View Replies !
Create Multimap Link With Database Field Values - How?
I've got a MySql database that stores (amongst other things) a latitude and longitude for a place. I want to create a hotlink on my page listing that links to a multimap.com map for each record. For example, for 10 Downing Street London, Multimap use the format: PHP Code:
View Replies !
Saving Result Of Function Without Being Echoed
I am trying to save the function "rand(1, 1000000)" in a variable but when I am for example trying: $randomnumber = rand(1, 1000000); it is executing it right ahead while when i try $randomnumber = "rand(1, 1000000)"; or $randomnumber = 'rand(1, 1000000)' It is saving rand(1, 1000000) as variable. But what I need is a variable saving the result of rand(1, 1000000) so the number does not change either. Any ideas how I would do this?
View Replies !
Accessing Session In A Php Page Echoed By Fstream
if I load a php page from controller.php like this: $handle = fopen("http://localhost/MvCphp_1.0/View/maincatgory.php", "rb"); echo stream_get_contents($handle); fclose($handle); then the created session, in the file where I am running the above code, for instance $_Sesssion['hr']='ge'; will not be accessible in echoed file above "maincatgory.php" I don't know why? and I want to know how can I access...?
View Replies !
Get A Database Stored Date Echoed On A Website
I'm trying to get a database stored date echoed on a website. The problem is it won't show up. This is the code piece getting the rows: $row3 = mysql_fetch_array($result); This is the piece declaring date to $actualdate: $actualdate = $row3['date']; This is the piece echoing the date: echo $actualdate; I'm sure I'm doing some damn mistake here, it's probably really easy for you other guys to solve.
View Replies !
Hidden Input Actually Needs To Be Hidden
I have a form in a table, which takes users to the cart. I want to pass the image information (which is image_link, not shown here) onto the cart using POST (below) but without displaying the image on the initial form. Using input=hidden still shows the image. I can only think to put it in a <td> tag 0 px wide or something, but it seems a bit scrappy! Code:
View Replies !
Variable Won't Go In To Db Field!
I have this script that gets the name of all jpegs in a directory then passes the name along with other information into a database. With the exception of $image_name all variables are being passed correctly to a new record. However the field for $image_name is always blank even though $image_name echos the file name perfectl! I've tried both text and varchar for the mySQL field type and neither works. Code:
View Replies !
Printing Field/variable
I have a script for clients to update their information directly, when they submit the new information is printed for them to see. If they use a single or double quote in the information entered - the / character appears before it. How can I make this not appear?
View Replies !
Variable In Form Field
I want to put a variable as the content of a hidden field. I realise that normally you would just open up a set of php tags and echo the variable in which I have done in the past, although I need the whole form in php tags as I have made the form a function in order to hide it with sessions when no body is logged in. This seems to be causing a problem as I can't get the content of the variable into the field its just echoing the actual statement in. Code:
View Replies !
Set Variable Name Use Field Name From Table
I have a query string that sets the value of Variables below: if ($DB == "Departments") { $tracking_id = $data22['tracking_id']; $dept_name = $data22['dept_name'];} simple and straight forward. Now I would like to set a loop that would set the variable name and value based on the field names in the table queried. if ($DB == "Departments") { $querystring = "Select * from ".$DB; $result=mysql_query($querystring); while(($field = mysql_fetch_field($result))) { $field->name = $data22[$field->name];}} can I set the variable name using the $field->name if so how? I have tried this code with no luck and no luck searching. This is a small example. I have queries with fifteen plus fields. This would also remove the need to modify this code if a field needs to be added to the table. And yes I have had to add fields to the tables.
View Replies !
Text Field Variable
I'm new trying to use php forms. Trying to write what is typed into the text field to a file. But its not working. It makes the file, but the text field data is not written. Code:
View Replies !
Assign Variable From Database Field
Is there a way to assign a variable from a database field? I'm thinking along the lines of $make = $row_rsList['make']; $model = $row_rsList['model']; then they'll switch out based on my SQL WHERE statement. This valid syntax?
View Replies !
I Need To Compare Variable Against Database Field...
I have a variable coming into my script via a post operation. That variable ($fromFlash) is being sent to the script from a Flash movie and just contains a website URL. I have a MySQL database containing the names of organizations with their website addresses. I need to compare my variable against that database, to see if there is a match for the website address contained in the variable; if there is a match, I need to pull the record and send the organization's name back to my Flash movie -- if there is no match, I need to send an error message. Code:
View Replies !
Can I Set The Value Of A Text Input Field Using A Variable?
Is it possible to do something like this?: <input type="text" maxlength="10" length="15" value= some_string_returning_function($value) /> I am trying to send a form back to the user for him/her to correct a field, but i want the other fields (already validated) to still have what he had previously entered in them.
View Replies !
|