|
|
|
|
![]() ![]() |
Oct 24 2004, 11:08 AM
Post
#1
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 24 Joined: 24-October 04 Member No.: 1,919 |
Ok, so I'm using the include() function on my website. Problem is I'm trying to include a search engine form into the layout which is stored in a variable, except the form has an if statement in it and I can't seem to get it working. Here's the code I'm trying to include...
CODE <form method=POST action=search.php> <p>Search:<br> <input type=text name=search size=20 class=textbox size=15 value= <?if (isset($_POST['search'])){ echo $_POST['search']; } ?> ><input type=submit value=Submit> </form> Just wondering if it is possible for me to put this form with the if statement into a variable, or if there's another way that I could go about doing this. Thanks. |
|
|
|
Oct 27 2004, 08:14 AM
Post
#2
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 114 Joined: 9-August 04 From: Suzhou Jiangsu China Member No.: 743 |
try:
CODE <form method=POST action=search.php> <p>Search:<br> <input type=text name=search size=20 class=textbox size=15 value= <? if (isset($_POST['search'])){ echo $_POST['search']; } ?> ><input type=submit value=Submit> </form> or CODE <form method=POST action=search.php>
<p>Search:<br> <input type=text name=search size=20 class=textbox size=15 value= <?php if (isset($_POST['search'])){ echo $_POST['search']; } ?> ><input type=submit value=Submit> </form> |
|
|
|
Nov 6 2004, 10:39 AM
Post
#3
|
|
|
Newbie [Level 1] ![]() Group: Members Posts: 12 Joined: 6-November 04 Member No.: 2,152 |
To increase the "readability" of the code I would do it like :
<form method=POST action=search.php> <p>Search:<br> <?php echo "<input type=text name=search size=20 class=textbox size=15 value=".$_POST['search'].">"; ?> <input type=submit value=Submit> </form> You actually dont have to take the test isset for this. It is only useful for SQL queries that would generate an error if they get blank parameters |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 8th October 2008 - 03:49 AM |