| | |
Passing variables into form fields
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Oct 2004
Posts: 14
Reputation:
Solved Threads: 1
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]
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]
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?
[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
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.
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
http://www.vivaci.net - Quality Webhosting
http://gaming.vivaci.net - FAST UK Gaming servers
http://www.getsigned.org - Free Image Uploads
•
•
Join Date: Oct 2004
Posts: 14
Reputation:
Solved Threads: 1
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
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
![]() |
Similar Threads
- passing values from a form to a dialog form (VB.NET)
- Passing variables to a different server (PHP)
- Passing Variables/Parameters - By Ref/Value? (Computer Science)
Other Threads in the PHP Forum
- Previous Thread: $_POST - What does it mean?
- Next Thread: Display URL
| Thread Tools | Search this Thread |
# 5.2.10 access action address alexa apache api array auto autoincrement broken cakephp checkbox class classes clean clients cms code cron curl database date dehasher destroy directory dissertation domain dynamic echo$_get[x]changingitintovariable... email encode error errorlog fairness fatalerror file folder form function functions google href htaccess html image include indentedsubcategory ip javascript joomla legislation limit link load local login masterthesis memberships menu multiple multipletables mysql mysqlquery newsletters oop open passwords paypal pdf persist php popup provider query radio random script search secure server sessions simple sockets source space spam sql system table tutorial upload url user variable video voteup web youtube






