Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Displaying Variables In Form Objects


I'm trying to display information within a lookup box and a text area box. Here's the code for the form objects:

<TEXTAREA NAME="BodyText" CLASS="InputTxtBoxes" MAXLENGTH="10000" COLS="100" ROWS="20" VALUE="<?php echo $BodyText ?>"></TEXTAREA>

<SELECT NAME="AuthorName" CLASS="InputTxtBoxes"><OPTION VALUE="<?php echo $AuthorName ?>"></OPTION>

When I print these variables out they do contain the correct values, but when I try and display them within these form objects they don't work at all. The BodyText is stored in a blob in the database and usually contains relatively large amounts of data (300 - 500 words). Any ideas?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Displaying Variables In Html Form
Below i have a form which i want to be filled with variables sent from the last page. can anyone tell me why the variables are not showing - I think its something to do with the syntax of the php inside the html form Code:

Session Variables/objects And ADODB Question
I a writing my first PHP 5 web application.

I don't want to use global variables.

I'm using the normal PHP 5 sessions, not the ADODB sessions.

I'd like to add the ADODB connection object to the session using a session
varible and then use the connection object on a different page by
referencing the connection object in the session. (I don't want the overhead
of having to connect to the database) Is this even possible and if not what
is the best way of going about this? eg.

----------------------------------

===========
Login.php
===========

session_start();
....
$conn = &ADONewConnection('borland_ibase');
$conn->PConnect($databasename,$username,$userpassword);
....
$_SESSION['connection'] = $conn;

==========
LoggedIn.php
==========

session_start();
....
$conn = $_SESSION['connection'];
$recordSet = &$conn->Execute('select * from table');

---------------------------------------

PHPClass Form Objects?
Are there any PHPClass scripts that provide us with a different look &
feel for web page controls such as buttons, text boxes, dropdown
lists, etc.?

Form Objects: How Refer To Them?
I have a form populated from the DB. The form additionally has input fields and a submit button.

How do I refer to the objects of the form, e.g. price, that are not the input or the submit? I want to put them into a SESSION variable to populate the cart.

I have tried using "object" notation, but I can't seem to refer to the object items using POST Code:

Passing Objects Form One Page To Another
Is it possible to transfer objects derived from a class form one page to
another?

I made 2 testscripts:

person.php
-------------------------------------
<?php

class person {

private $_name;

public function setName($name) {

$this->_name = $name;

}

public function getName() {

return $this->_name;

}

}

$p = new person();

$p->setName("Jim");

$safep = urlencode(serialize($p));

header("Location:person2.php?data=".$safep);

exit;

?>

person2.php
---------------------------------
<?php

class person {

private $_name;

public function setName($name) {

$this->_name = $name;

}

public function getName() {

return $this->_name;

}

}

$x = unserialize(urldecode($_GET['data']));

echo $x->getName();

?>

But this does not work for me....

Displaying Two Variables
From an Array in a Text Box.

Here is what I am trying to do. I've tried several different ways but the page keeps breaking.

$data = mysql_query("SELECT * FROM ecampaign WHERE id=2")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{

Print "
   <textarea cols='70' rows='4' name='message'>".$info['header']. .$info['message']."</textarea>";

Displaying Variables In PHP Mail
I send the mail by using:

Displaying Variables Without Nesting Php Tags
I know you can't nest php tags so if you're already inside a code block and outputting a table via echo and want to popultate the value of a text box, how do you format the syntax?

$result = @mysql_query($query);

if (mysql_affected_rows() == 1){

$firstname = $result['user_fname'];
The above gets a row, I'm not sure if the last line is necessary, now in the form what goes between the VALUE attribute to make it display the data from the query? Code:

Using Database Objects Within Other Objects. Inefficient?
I've defined a Database class with methods to call mysql_query(), etc. The connect() method makes a persistent connection. I've also defined a Member class to hold functions and data for users. PHP Code:

Values Not Displaying In Second Form After Post.
I have two forms that are used to collect user information. The first one
takes user inputted values such as fullname, city, address etc. I want these
values to display in the second form when it is called. Both forms are .htm
files that call themselves when the submit button is press via the following
command in each form:

<form method="post" action="<?php $server['PHP_SELF']?>">

The server is set to parse .htm files as php. Everything else is working
fine and all the validation checks are working fine. Based on certain
validation checks that are within the form php code, the user is either left
on the input form page to correct errors or if there are no errors the user
is passed to the next form via a Java call....

<script language="javascript">
<!--
location.replace("order2.htm");
-->
</script>

I have even put a session_write_close() before the redirect hoping this
would fix the problem of not displaying the inputted values from the first
form into the second form.

The server value for global variables is set to ON.

In the second form I have tried to display the values from the first form
after the POST using the following three methods:

$fullname;
echo $HTTP_POST_VARS['fullname'];
echo $_POST['fullname'];

Nothing works...

Displaying Data In A Editing Form
I have a form that has three checkboxes. A,B&C. Data from A & C has been entered into the database by serializing it.I now want to create a edit form where the user can view his choices ticked.

<form action="postoDb.php">
A<input type="checkbox" name="Choice[]" value="A">
B<input type="checkbox" name="Choice[]" value="B">
C<input type="checkbox" name="Choice[]" value="C">
</form>

//postodb.php
$bn = serialize($Choice);
sql ="insert into table (choice) values('$bn')";

Displaying Information In A Update Form
I can display the information in a table.  But now I need to display it in a form, so I can edit it and then upload it to the database.  I have the form from my upload page, But I can not seem to get the information to appear back in it. Code:

Displaying A Html Form With Php Echo
I a have a form for users to enter details. Before the form is shown the user enters a number of values they need to enter.

So the amount the user enters first is the anount of rows the user is given to enter there details. To do this iv used a while loop and a $count variable.

My problem is with echoing the form. I must be doing it in a completly non standard way as allthough firefox displays it perfectely ie doesnt display it at all. Code:

PHP Displaying Info Input On HTML Form
I'm in an exercise where I've created an order form in HTML. The form displays properly and allows me to input certain test order info just fine. The relevant lines in the HTML form are: Code:

Stripping Http:// Form A Url When Displaying To A Page...
Hi I'm trying to display URL's in my link exchange like google does.

Here is the function to display the Link, Description and URL:

Form Variables To Session Variables
I am writing a small script that consists of two pages:  page one displays a bunch of values from a DB (ie. First Name, Last Name, Phone Number).  On this page you will find a form that follows this format:

<input type="text" name="edit_firstname" size="20" maxlength="35" value='Bob'>
<input type="text" name="edit_lastname" size="20" maxlength="35" value='Smith'>
<input type="text" name="edit_phone" size="20" maxlength="35" value='5552222'>

So when you see the page there will already be a 'default' value in each line (which is information extracted from a DB).  This works perfectly and has been tested thoroughly.

On the second page I have the following code:

$editfirstname = $_POST['edit_firstname'];
$editlastname = $_POST['edit_lastname'];
$editphone = $_POST['edit_phone'];

What I am trying to do is this:  the default value for edit_firstname from the form is 'Bob' by default, but the user can change this in the input field on the first page.  This value, whether changed or unchanged, should then be stored as edit_firstname and by calling up the function $_POST[''] on the second page I want to transfer the value to the variable $editfirstname. 

However, it seems that $_POST['edit_firstname'] and the other fields do not return a value at all, hence $editfirstname = '' or $editfirstname = 'NULL'.  I have never tried to do things this way before. 

Signup Form Displaying Wrong Passwords (PASSWORD HASH)
I recently created a signup form with a user password. The forms are working, however, when I retrieve the record in MySQL the passwords are jumbled numbers and letters -not the correct passwords.

I believe this is called password hash. Why is the hash generated? I created a few user accounts but I can't login as the password entered is not the same as the myslq password generated by the hash..??

How are users suppose to login? What if they lose their password...how do I send them their password if I have a 'password hash'?

Displaying Data From Mysql Database In A Drop Down List On Form.
I'm trying to do is display data from two different mysql tables from the same database in a drop down list on a html form. I have a fixtures table with the player1(userid), player2(userid), gameid, game, score1 and 2, what I want is to use the userid to get the players first name and surname from the members table (as it is a unique id), I need to do this bit before displaying it in the drop down. I think i need 2 querys to do this but when I have tried it it just echo's a blank value or the userid not the forname and surname that I want. I'm using the fetch_array function but just can't see where I'm going wrong, Code:

Validation Errors From Displaying On Form Page Load Instead Of Submit
creating two forms and they work fine. Problem is that the validation errors display immediately on page load instead of on submit. Here's the full code for the form parsing: Code:

Following Up Form Variables
i've coded a website to take information from a user, and then output it to a printable page to send in. The site is actually for a non-profit org, and this is for a contribution form.

I have a checkbox place to put into a variable called $bird[]. $bird[] prints out fine on the page directly after, but how do I keep the value of it and send that variable on to the next page? So on the next page I can also print out the value of $bird[]. On the second page, I used: PHP Code:

Form Variables
Wonder if there is any way to check all variables through a loop when a form is submitted.
I have few checkboxes (chk1,chk2,chk3...) in a form and in a php file I wanted to go through a loop to check which checkbox is 'on' and then so something with that variable.

Using Variables From Form
I've just started learning php and I hope you guys could help me with
this problem. I've found a useful pice of code from a book to make a form
and I would like to use it. I would like to print the variables (input)
on the screen , but I can't make it work. I think I have to do something
with an array, but don't know what. I've tried

$field = $_POST['field'];
echo $field;

and also

$arr = $_POST['array'];
print_r($arr);

but it doesn't work.

Could some one show me what I'm missing?

########################### code ###################################

<?php

// new function
echo "<br><br><h4>second function</h4>
";

function print_form($action="", $method="post")
{
if (empty($action)){return FALSE;}
echo "<form action=$action method=$method>
";
$numargs = func_num_args();
for($i = 2; $i < $numargs; $i++)
{
echo "$i <input type = text name =". func_get_args($i) . ">
<br>
";
}
echo "<input type=submit>";

echo "</form>";
}
print_form("autoform2.php", "", "field", "field2", "field3", "field4");

// testing if the variable exist...and it doesn't...
if(isset($_POST['field'])){
echo "exist";
}
else {
echo "does not exist!";
}

?>

########################### end code ##################################

Help With Displaying Selecting A Date Range And Displaying Results
I wish to create a simple form that allows the selection of a start date and a stop date with the ability to select what columns to be displayed in the result page.

Form Variables Without Submit
Is there a way to pass variables from a form to PHP without submitting the form? ie. retrieving a user's selection from a picklist or checkbox.

Can You _POST Variables In Php Without Using A <FORM>
The question I have, is it possible for a php script which is used to
validate values submitted in a form, to then post these values onto
another script/page or even back to the calling form?

i.e. the application I have in question is a login.htm page with a
verify.php script The login.htm has a Form which captures login_id and password which are posted to verify.php

verify.php checks the id and password against the database.
if the check succeeds I use $_SESSION to track the logged in user into
the page. if the check fails, I use $_SESSION["error"] to set an error message
and then jump to login.htm, but I've lost the userid.

The only way I can see of transferring the userid (and some other data)
is by calling header ("Location: login.htm?id=$uid");
and then have some php code in login.htm to $GET['uid'] and pop that
into the user field on the form.

Is there any easy way I can post this data back without using a <FORM>
or at least a form that can be auto-submitted?

Find Form Variables
Is there a way to read the variable names passed by a form if you dont know their names.
I have a site where the users can edit a form but I need to then process it.

Passing Variables From A Form
Well I am having some strange problems with a web-based form that is used for users to submit data. I have moved the form and accompanying PHP files across from a Redhat 7.3 install to a new Redhat 9 server running Apache 2.0.40-21, with php-4.2.2-17. So, it is stock standard. Everything was working ok on the Redhat 7.3 install. The troubles I have run into is when I try and pass a variable from a form such as below: Code:

Passing Form Variables To A Pop-up
I've searched the forums for this, but haven't seen any posts or solutions about this particular problem...I have a form in a php script that submits like this: Code:

Form Variables Gone Missing
hope I'm on-topic here - couldn't find any leads with a search so
maybe someone has an idea.

I've got a PHP form that is supposed to set some variables from
its fields and then call itself by the POST method.

Here is e.g. a minimal test version called "top.php":-

#!/usr/bin/php
Content-type: text/html

<HTML>

Welcome <?php echo $_POST["name"]; ?>.<br />
You are <?php echo $_POST["age"]; ?> years old! <br>
Welcome <?php echo $name; ?>.<br />
You are <?php echo $age; ?> years old! <br>

<form action="top.php" method="POST">
Enter your name: <input type="text" name="name" />
Enter your age: <input type="text" name="age" />
<input type="submit" />
</form>

<? phpinfo(); ?>

</HTML>

When I enter data in the fields name or age, it just gets ignored,
goes missing, thrown away by PHP. The first 4 lines that should
output this info show that the variables are all blank.

The phpinfo() call at the end shows me clearly that register_globals
is on.

The only way I've found so far is with the GET method - there the
expected arrays and variables are also broken,
but $_SERVER["REQUEST_URI"] is correctly set (yipee!) and so
I can parse that myself - sort of defeats the point of PHP though.

What could be the problem here?
Is there some other setting I'm missing?
This stuff all worked without a hitch in PHP3 - has something
else been broken in the name of security?

Passing Variables Through A Form
I have a setup where I am displaying lots of information, all of it comes from contact forms and is stored in a database. Then can be viewed on one page, through the scripts. One feature is that you can click on an email address to send an email to that specific user. When you click their email, the form comes up fine, and I have been playing with this for awhile.. I am having trouble getting the variables passed through so that I can send the email and update the database. Code:

Passing Form Variables
I'm trying to make a page that will let you change the order in which some items are displayed. The problem I'm having is passing back the id value of the item that you want to move up or down in the display order. Here is the code:

Passing Form Variables
Is there a way to read the variable names passed by a form if you dont know their names. I have a site where the users can edit a form but I need to then process it.

Session Variables In A Form
i want to create a form that updates a users account details...is there a way that i can get the form to show the users current details in each text box? then the user clicks on that box to edit the deails?

also how would i structure a query so that it only updates the edited fields? and keeps the rest the same? Code:

Form Variables And Text Characters
Well I´m having trouble with text formatting I think.
You see I have a flash form, which sends variables
via POST to a php file that looks like this:

Passing Variables Through FORM -> IMAGES
I have to say this is bugging me, I'm trying to pass a variable through a form, but instead of "select" then "submit" type of form, I am trying to use IMAGES instead...

I am trying to pass the variable ($lang) , depending on the value of this variable, the page will look different (English or French )

I guess I am doing this the wrong way, I thought by giving both images the same name, but different values, it would work.... but it is not working.

here is the HTML code of the form itself :

Code:
<!--LANGUAGE SELECTION -->
<FORM NAME="pick_lang" METHOD="post" ACTION="<? echo "$PHP_SELF"; ?>">
<table border="0" cellpadding="0" cellspacing="0" width="165">
<tr>
<td rowspan="2"><img name="shadow_drapeau_r1_c1" src="tble_img/shadow_drapeau_r1_c1.gif" width="102" height="21" border="0"></td>
<td>
<INPUT TYPE="image" BORDER="0" NAME="lang" value="en" SRC="tble_img/shadow_drapeau_r1_c2.gif" WIDTH="21" HEIGHT="14">
</td>
<td rowspan="2"><img name="shadow_drapeau_r1_c3" src="tble_img/shadow_drapeau_r1_c3.gif" width="8" height="21" border="0"></td>
<td>
<INPUT TYPE="image" BORDER="0" NAME="lang" value="fr" SRC="tble_img/shadow_drapeau_r1_c4.gif" WIDTH="21" HEIGHT="14">
</td>
<td rowspan="2"><img name="shadow_drapeau_r1_c5" src="tble_img/shadow_drapeau_r1_c5.gif" width="13" height="21" border="0"></td>
</tr>
<tr>
<td><img name="shadow_drapeau_r2_c2" src="tble_img/shadow_drapeau_r2_c2.gif" width="21" height="7" border="0"></td>
<td><img name="shadow_drapeau_r2_c4" src="tble_img/shadow_drapeau_r2_c4.gif" width="21" height="7" border="0"></td>
</tr>
</table>
</FORM>
<!--END LANGUAGE SELECTION -->

I don't want to set images with links (<A HREF="$PHP_SELF?lang=$lang"> works, but I want the URL to remain clear of data)

Form Variables Not Printing In E-mail
This is my first attempt at a php-based form at work in order to personalize the form response with the submitter's name. When I submit the form, all that's returned to me via e-mail is the header information. I've been searching google but can't figure out what I've done wrong. The php to process the form is this:

How To Make PHP 'grab' Variables From A WML Form
I really can't get forms to pass data to my scripts. Now someone mentioned something about grabbing it and posted some code, but for the life of me I cannot find the email/post/whatever the hell it was, so can someone please tell me how a PHP script can be made to 'grab' a variable from a form.

Pass The Variables In The Form Of Sessions
If I have something like this how can i pass the variables
in the form of sessions to another page, where i Can calculate based on the products selected, very much like a shopping cart! PHP Code:

Editing Submitted Form Using Variables
I'm working an e-mail form for my web page. I want people to be able to fill out information and when the click submit, get a page that basically says, "Here is the information, is it correct?"
Then they can click either, "Yes" (and it sumbits), or "No", and it goes to another page set up like the form filled out the first time, and grabs the variables and places them in the "values". This is the code I have so far: Code:

Variables Not Passed From Url Or Form To Page
I use a Mac at home running OSX 10.2, and use the Apache PHP MySQL trio for developing and testing sites. I've had very good experiences with this setup and have had no major problems till now.

I noticed recently that variables added to the end of the url (the get method, ...url/page.php?var=value) are not passed to the script within the page. Forms using either the get or post method have the same problem. For example, a page named "foobar.php" containing this: Code:

Getting $_POST Variables From Form In A Function
I've loaded various thoughts I've collected into mysql. I want to write an
app, all in one file, that has the following features:

1. On initial entry, selects and displays the thoughts ( might add
pagination later - there aren't alot of records, for now.)
2. This main page includes separate forms near the top with submit buttons
to search, add a thought, view all thoughts, etc. The action for each form
is to call this same page. The submit buttons and thoughts are printed from
a function.
3. In the main logic, I am trying to do a $_POST and if isset() on each
submit button name and then call a corresponding function, do whatever it
has to do, unset the form variable and continue back to the main display.

The problem is that it's not calling any functions. The error log says that
the name of each submit button in my $_POST[] statements in the main logic
is an undefined index. I presume that they are undefined in the main logic
because the forms were defined in a function.

Is there anyway to access, in the same page, form variables that were
declared in a function on that page?

Form Variables In The Address Line.
I have created a form with hidden variables and submit button which
initiate downloading of a new page. After submit-button is pressed and
new page is downloaded I can see values of all hidden variables in the
address line of the browser. It is strange that another form does not
produce this effect (variables in address line). I cannot find out
which difference in forms originates different behavior. May be you
have some ideas?

Form Variables Not Being Read By Php Script
I've got an HTML form that submits to a php script. Now, this was done on one server, and worked perfectly fine. I upload to another server, and the variables are not being read by the script at all! If I set method=get, the variables are in the url, but the php code doesn't seem to be getting them at all. any suggestions?

Form Button Names As Variables
perhaps I am just a little tired, but I am having trouble with my form
buttons.

Firstly I name them like this
name="round".$counter."heats"
which results in variables
$round1heats
$round2heats
$round3heats
etc...
now, when I select button named ... "round1heats" ... I want to use the
variable $round1heats to remove the button "round1heats", and display heats
set for the round. To do that I assumed that I would have to:-
IF(isset($round1heats)){
show other stuff instead etc
}else{
generate and print html for button "round1heats"
}

My problem is, since all this is dynamic, since the number of heats is
variable, and is dependant on DB entries, how do I generate the $round1heats
used in the isset() so that it is recognised as a variable by the isset().
I have tried, to concat the bits as I have done in the naming of the button,
but, unsurprisingly, it spits out errors ;)
[note, $counter is still available, and is limited to the number of rounds
registered in DB.]
OR, have I been barking up the wrong tree altogether?

Missing Something In Passing Form Variables
I have the following code to select an item from a drop down menu and
call the same script over again. I am expecting that after the first
time the script is run the first echo would produce the selected PBX
name (e.g. FMSite) but instead I get FMSitepbx=FMSite.

Needless to say this screws up the further processing I want to do. What
I really want to do is set a cookie containing the selected PBX name so
other scripts can get the cookie and provide specific data.

<?php

echo($_POST['pbx']);
$dbcnx = @mysql_connect("localhost", "***", "**********");
if (!dbcnx){
echo( "<p>Unable to connect to database.</p>");
exit();
}
if ( !@mysql_select_db("inet") ) {
echo( "<p> Unable to locate the iNet database. " . mysql_error() .
"</p>" );
exit ();
}

$query = 'Select Name from PBX order by Name'
$result = mysql_query ($query)
or die ('Query Failed');
echo '<form action="setpbx.php" method="POST">'
echo 'Select PBX <select name="pbx">'
while ($row = mysql_fetch_array ($result)) {
echo '<option value="' . $row['Name'] . '">' . $row['Name'];
}
echo '</select>'
echo '<input type="submit" value="Submit">'
echo '</form>'

?>

Keeping The Variables From Form To New Page
On a web page that I am working on there is a lead generator on the left side that asks for the persons name, phone number and email address. Currently when someone fills in that information and clicks "continue" it will send an e-mail as well as inputs that data into mySQL database.

What I want it to do is just that but then take the person to a continued form asking more questions, but without them having to re-fill in their name/phone/email. Basically this "continued form" can be accessed seperately, so it cannot be something where the continued form only works once someone fills out the mini form on the left side of any page on the site. Code:

Sending Variables To An HTML Form
I have a form in an html file that sends to a PHP file for processing. The information is properly sent to the PHP file and it is processed and validated. What I want to be able to do is this:

If there are errors in the form (found in the PHP validation), send the user back to the HTML form with the form still filled out with the information that the user had entered.
I do not want the fields with errors sent back, just the good information. There are two seperate files, the html file and the PHP file.

Changing Variables In Another File Through A Form.
I'm trying to change the value of some variables in an include file through a form.
I have modsettings.php which contains the variables to change, and modarmin.php which has a form that contains radio buttons which need to switch the variables in modsettings.php to either true or false. Then refresh the form page with the updated values. Currently when I submit the form I am taken to the file modsettings.php and the variable values are not changed. PHP Code:

Populating Form Fields With Variables
The script itself works fine: mail gets sent. If there are any missing fields the form displays again with a list of the missing fields, but I can't get the form fields of the reloaded form to be populated with teh existing values. PHP Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved