User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 401,669 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,559 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 12958 | Replies: 5
Reply
Join Date: Jan 2005
Posts: 13
Reputation: nikez is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nikez nikez is offline Offline
Newbie Poster

Solution Passing variables into form fields

  #1  
Jan 10th, 2005
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2004
Location: France / Paris
Posts: 14
Reputation: fpepito is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
fpepito fpepito is offline Offline
Newbie Poster

Re: Passing variables into form fields

  #2  
Jan 11th, 2005
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]
Reply With Quote  
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Rep Power: 11
Solved Threads: 101
Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: Passing variables into form fields

  #3  
Jan 11th, 2005
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?
Alex Cavnar, aka alc6379
Reply With Quote  
Join Date: Jan 2005
Posts: 13
Reputation: nikez is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
nikez nikez is offline Offline
Newbie Poster

Re: Passing variables into form fields

  #4  
Jan 12th, 2005
:lol: So simple when you think about it...Thanks so much

JameZ
Reply With Quote  
Join Date: Sep 2004
Location: in the j00-kay
Posts: 114
Reputation: ReDuX is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
ReDuX's Avatar
ReDuX ReDuX is offline Offline
Junior Poster

Re: Passing variables into form fields

  #5  
Jan 12th, 2005
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.
I'm pink, therefore, im spam.
http://www.vivaci.net - Quality Webhosting
http://gaming.vivaci.net - FAST UK Gaming servers
http://www.getsigned.org - Free Image Uploads
Reply With Quote  
Join Date: Oct 2004
Location: France / Paris
Posts: 14
Reputation: fpepito is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
fpepito fpepito is offline Offline
Newbie Poster

Re: Passing variables into form fields

  #6  
Jan 12th, 2005
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 7:14 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC