Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2004, 03:49 AM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query String not passed on from form submission

I have recently installed WinLAMP02 (PHP, MySQL, Apache for windows)

The problem I face is that when a form is submitted no query string is passed on to the script page. So the message I get is you have not entered/you have not selected anything. Otherwise directly I am able to query database.

Would someone please help me.

thanks
Thomas

 
Old May 3rd, 2004, 03:55 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Hi check the action and method attributes of your HTML form, e.g.

<form method='get' action='myscript.php'>

If that doesn't help please post some relevant snips of your code so we have something to go on.

Regards,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
 
Old May 3rd, 2004, 04:20 AM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Rich,

The problem seems to be something else. following is the code:

<FORM METHOD="GET" ACTION="<?=cnfg('deDir')?>search.php?doSearch=1">
    Enter Keyword:
    </td> </tr> <tr>
    <td valign="top">
    <INPUT TYPE="TEXT" NAME="search" SIZE="30">
    </td> </tr> <tr>
    <td valign="top">
    Search In Category:
    </td> </tr> <tr>
    <td valign="top">
    <SELECT NAME="category">
    <OPTION VALUE="none">All Categories</OPTION>

    <?php

    get_cat_options();

    ?>

    </SELECT>
    <BR>
    <INPUT TYPE="SUBMIT" NAME="submit" value="Submit">

    </td> </tr> </table>

    <INPUT TYPE="HIDDEN" NAME="searchType" VALUE="keyword">
    </FORM>

Actually this problem is applicable to every form that I have. Earlier they were working fine but it seems after this new installation there are some problem.

After clicking the submit button nothing changes (no error message also) except the url, which changes to the script page.

Thanks very much for the help.
thomas

 
Old May 3rd, 2004, 04:44 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Hi Thomas,

This isn't a properly nested <form> tag! You've left out the start of the table.

Code:
<form method="get" action="<?php echo cnfg('deDir'); ?>search.php?doSearch=1">
    <table>
        <tr>
            <td>
                Enter Keyword:
            </td>
        </tr>
        <tr>
            <td valign="top">
                <input type="text" name="search" size="30" />
            </td>
        </tr>
        <tr>
            <td valign="top">
                Search In Category:
            </td>
        </tr>
        <tr>
            <td valign="top">
                <select name="category">
                    <option value="none">All Categories</option>
                    <?php
                        get_cat_options();
                    ?>
                </select><br />
                <input type="submit" name="submit" value="Submit" />
            </td>
        </tr>
    </table>
    <input type="hidden" name="searchType" value="keyword" />
</form>
What did I do to your code? I made it readable and XHTML conformant:
http://p2p.wrox.com/topic.asp?TOPIC_ID=4028
http://p2p.wrox.com/topic.asp?TOPIC_ID=11967

Are you using the $_GET superglobal in search.php to access the variables?

How about error reporting, is error_reporting set to E_ALL in php.ini? And does display_errors have a value of 'on' (it's turned off by default in more recent installations of PHP)? php.ini is the PHP configuration file, you can find this file in the Windows directory, open it with a text editor to make changes. Be sure to restart Apache after any changes to the file.

Ok, that all isn't going to do you any good if you aren't seeing the query string in the URL after pressing submit. You didn't tell me whether you saw the query string in the URL. If not, try modifying your mark-up like that shown so that every tag has both an opening and closing tag. I've never tried doing the GET method with the form action already containing a query string, so I dunno about that. For the sake of consistency I'd recommend you place that value in a hidden field.

hth!


Regards,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
 
Old May 24th, 2004, 04:54 AM
Registered User
 
Join Date: May 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Rich,

I got it working. The problem was with $_GET.

Sorry for late reply.

thanks very much

 
Old May 24th, 2004, 12:01 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Hi Thomas,
I was recently fooling around with a form that does something similar, that is contains a query string in the action and uses a 'get' method to post. The problem I had with that approach is the browser overwrites the query string with any fields in the form, however, using a post method I could send data along using a query string in the action with no problems.

Regards,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::





Similar Threads
Thread Thread Starter Forum Replies Last Post
string being chopped off when passed through url ronny Classic ASP Basics 6 October 30th, 2007 09:53 AM
form submission...help!? mdbrueckner ASP.NET 2.0 Basics 1 September 19th, 2007 06:16 PM
Calling vbscript function(passed value string) manish.sharma04 BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 0 May 7th, 2006 11:50 PM
Simple Form Submission Maxood Beginning PHP 3 July 17th, 2004 06:03 AM
conditional form submission moushumi Classic ASP Basics 1 March 30th, 2004 08:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.