newbie form help

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a search form that I have created.  When you submit the form, I want  
to run an my update form based upon the search criteria.

Here is most of my code for my search page:

<form name="search_board" method="post" action="process_order.php">
    <table width="640" border="1" cellpadding="5" style='border-collapse:  
        <td width="606" bgcolor="#CCCCCC"><div align="center"><strong>Search  
for a Project</strong></div></td>
        <td height="131"><div align="center">
          <table width="100%"  border="0">
              <td width="34%"><div align="right">Board Number: </div></td>
              <td width="42%"><div align="left">
                <input name="board_no" type="text" size="25">
              <td colspan="3">&nbsp;</td>
          <input type="submit" name="Submit" value="Submit">

Here is the start of my code for the process_order page:


        $bn = $_GET['board_no'];

        include 'config.php';

        /*** create a new mysqli object with default database***/
        $connection = mysqli_connect($hostname, $username, $password,  
$dbname) or die ("Unable to connect");

        /*** our SELECT query ***/
        $query = "SELECT id, board_no, mac_address
        FROM production where board_no = '$bn'";

        //excute query
        $result = mysqli_query($connection, $query) or die ("Error in query:  
$query. ".mysqli_error());

        //create list of variables from query results
        list($id, $board_no, $mac_address) = @mysqli_fetch_row($result);

        // free result set memory

        // close connection

When I run the page(s) I get the following error:

Notice: Undefined index: board_no in  
c:\Inetpub\wwwroot\production\process_order.php on line 3 (which is $bn =  

Not sure why I'm having troubles with this.  Any help would be greatly  
appreciated.  Thanks.


Re: newbie form help

Hello --

The problem that stands out the most is that you're attempting to pull
data from $_GET when your form method is set to POST.  Change the
variable in your script from $_GET['board_no'] to $_POST['board_no']
and everything should be well with the world again.  :)


Auddog wrote:
Quoted text here. Click to load it

Re: newbie form help

Auddog wrote:

First of all, thank you for posting the code.
It's appreciated.

Quoted text here. Click to load it

This means that the superglobal array $_GET does not have an index named
"board_no". The method you specified for the form is POST, so PHP will
populate the superglobal array $_POST.

If you replace your
    $bn = $_GET['board_no'];
    $bn = $_POST['board_no'];
it will be ok (hopefully).

Or you can use the $_REQUEST superglobal array instead and not worry (*)
about whether user data comes from GET, POST or COOKIE.

(*) Or, to put it another way:
Or you can use the $_REQUEST superglobal array instead and always worry
about whether the data comes from GET, POST or COOKIE :)

I (almost) never check the dodgeit address.
If you *really* need to mail me, use the address in the Reply-To
header with a message in *plain* *text* *without* *attachments*.

Re: newbie form help

Thanks for all the help.  That's what was causing me the problems.  I knew  
it was something that I was over looking.  I should have looked at the form  
to see the POST command.  Thanks for showing me the _REQUEST superglobal.  I  
checked that one out also and will start looking to use it.

Thanks again.


Quoted text here. Click to load it

Site Timeline