944,191 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 23107
  • PHP RSS
Jan 10th, 2005
0

Passing variables into form fields

Expand Post »
Hey,

Does anyone know how to pass a php variable into a form field? I want to reproduce what the user typed into a text box in another text box. Is this even possible?

Thanks,
JameZ
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nikez is offline Offline
13 posts
since Jan 2005
Jan 11th, 2005
0

Re: Passing variables into form fields

Hello nikez,

Look at this example,
and try it in http://www.fpepito.org/php/test7.php

I hope that help,

fpepito

[PHP]
<?

if (!isset ($autor)) {
$autor = "pepito";
}

echo "<FORM ACTION=$PHP_SELF>\n";
echo "Autor : <INPUT TYPE=TEXT NAME=autor VALUE=$autor><BR>\n";
echo "<INPUT TYPE=submit value=\"Send the variable\">\n";
echo "</FORM>\n";

?>
[/PHP]
Reputation Points: 10
Solved Threads: 1
Newbie Poster
fpepito is offline Offline
14 posts
since Oct 2004
Jan 11th, 2005
0

Re: Passing variables into form fields

Have a question for you:

[php]
<?

if (!isset ($autor)) {
echo "<FORM ACTION=$PHP_SELF>\n";
echo "Autor : <INPUT TYPE=TEXT NAME=autor VALUE=Pepito><BR>\n";
echo "Text : <INPUT TYPE=TEXT NAME=text VALUE=port><BR>\n";
echo "After date : <INPUT TYPE=TEXT NAME=aft VALUE=2002-01-01><BR>\n";
echo "Before date : <INPUT TYPE=TEXT NAME=bef VALUE=2004-01-1><BR>\n";
echo "<INPUT TYPE=submit value=\"Identify\">\n";
echo "<BR><HR><BR>\n";
echo "</FORM>\n";
} else {
include "/home/httpd/html/PHP/connect.php";
connect_mysql();
$criteria = "";
if (isset ($autor) && !($autor == "")) {
$criteria .= " autor = '$autor'";
}
if (isset ($text) && !($text == "")) {
if (! ($criteria == "")) {$criteria .= " AND "; }
$criteria .= " desc_pt LIKE '%$text%'";
}
if (isset ($aft) && !($aft == "")) {
if (! ($criteria == "")) {$criteria .= " AND "; }
$criteria .= " data > '$aft'";
}
if (isset ($bef) && !($bef == "")) {
if (! ($criteria == "")) {$criteria .= " AND "; }
$criteria .= " data < '$bef'";
}



if (!($criteria == "")) {
$criteria = "WHERE ". $criteria;
}
$q = "SELECT * FROM fotos_file $criteria";
echo "$q<BR>\n";
$query = mysql_query ($q);
$res = mysql_num_rows($query);
echo "<BR>I found $res element corresponding of your demand";
}

echo "<BR><BR>\n";
echo "<BR><BR><HR><BR><BR><CENTER><A HREF=test6.txt>Load the source</A></CENTER>\n";

?>[/php]

What's all the mysql stuff for, just out of curiosity?
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003
Jan 12th, 2005
0

Re: Passing variables into form fields

:lol: So simple when you think about it...Thanks so much

JameZ
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nikez is offline Offline
13 posts
since Jan 2005
Jan 12th, 2005
0

Re: Passing variables into form fields

alc: the mysql 'stuff' collects variables from the form when submitted and performs a mysql database search for records that match the submitted information. In that case, autor, text, aft and bef.
Records matching those criteria will be counted and it will display the number of records found.
Reputation Points: 12
Solved Threads: 5
Junior Poster
ReDuX is offline Offline
127 posts
since Sep 2004
Jan 12th, 2005
0

Re: Passing variables into form fields

hello alc6379,

test6.php is one example about another thread 'Advanced mySQL Querys'.
Look at reference:
http://www.daniweb.com/techtalkforums/post67325.html


For this thread (Passing variables into form fields) I have write test7.php that is more simple

fpepito


sorry for my bad language, I hope that my examples is more easy to understand
Reputation Points: 10
Solved Threads: 1
Newbie Poster
fpepito is offline Offline
14 posts
since Oct 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: $_POST - What does it mean?
Next Thread in PHP Forum Timeline: Turck mmCache no more?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC