
- You are not logged in. | Login
January 18, 2007 9:03 am
- mdwb
- Member


Please Help!!!! :)
I have such problem. There is a search function on the site, everything works - user writes what he wants to find but after system finds the keyword field is empty.
<form action="search.php" "method="post">
<input name="keyword" type="text" size="50" title="Search" class="inputbox" id="keyword">
<input class="button" type="submit" name="Search" value="Search">
</form>
<?php echo "<script> alert('You searched: $keyword'); </script>\n"; ?>When appears alert keyword is empty
Don't be afraid of life, it is yours!
January 18, 2007 9:09 am
- PHPprof
- Member


Re: Please Help!!!! :)
<?php echo "<script> alert('You searched: $keyword'); </script>\n"; ?>is situated in the search.php ?
Try $_POST['keyword']
Last edited by PHPprof (January 18, 2007 9:10 am)
I'll come to win... wait...
January 18, 2007 9:12 am
- PHPprof
- Member


Re: Please Help!!!! :)
At the beginning of the code insert:
PHP code:
If (isset($_POST['Search']))
{
echo "<script> alert('You searched: $_POST['keyword']'); </script>\n";
}I'll come to win... wait...
January 18, 2007 9:16 am
- stp2233
- Member


Re: Please Help!!!! :)
That part of the code is in the index.php (for example)
PHP code:
<form action="search.php" "method="post"> <input name="keyword" type="text" size="50" title="Search" class="inputbox" id="keyword"> <input class="button" type="submit" name="Search" value="Искать"> </form>
And this one in the search.php
<?php echo "<script> alert('You searched: $keyword'); </script>\n"; ?>Do you have the same?
January 18, 2007 9:21 am
- mdwb
- Member


Re: Please Help!!!! :)
There are two single files - hndler form and just form, values are passed from the form to search.php
Don't be afraid of life, it is yours!
January 18, 2007 9:25 am
- PHPprof
- Member


Re: Please Help!!!! :)
mdwb wrote:
There are two single files - hndler form and just form, values are passed from the form to search.php
Insert the following code into the beginning of the search.php page:
If (isset($_POST['Search']))
{
echo "<script> alert('You searched: $_POST['keyword']'); </script>\n";
}I'll come to win... wait...
January 18, 2007 9:29 am
- mdwb
- Member


Re: Please Help!!!! :)
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in
Don't be afraid of life, it is yours!
January 18, 2007 9:32 am
- mdwb
- Member


Re: Please Help!!!! :)
Inserted onto the search.php the line:
echo "<script> alert('Вы искали: $keyword'); </script>\n";The problem was that I kept it in the first file, but I had to keep it in the second one
Thanks!
Don't be afraid of life, it is yours!
January 18, 2007 9:35 am
- PHPprof
- Member


Re: Please Help!!!! :)
MAke like you want but there is no need to create second file if 1 line can be done in that file. Put another value of the file into the form.
Code: php
<form action="<?=$PHP_SELF?>" "method="post"> <input name="keyword" type="text" size="50" title="Search" class="inputbox" id="keyword"> <input class="button" type="submit" name="Search" value="Search"> </form>
I'll come to win... wait...
January 18, 2007 9:39 am
- bandlist12
- Member


Re: Please Help!!!! :)
If (isset($_POST['Search'])) { echo "<script> alert('You searched: $_POST['keyword']'); </script>\n"; }
There is no need to add inverted commas. write $_POST[keyword]
January 18, 2007 9:41 am
- reetesh
- Member


Re: Please Help!!!! :)
If so, it is better to write:
echo '<script type="text/javascript">alert( "You searched: '.$_POST[ 'keyword' ].'" );</script>';
Last edited by reetesh (January 18, 2007 9:42 am)


