RE: Value of if(isset(X)) problem
| From: | Tim Ward | Date: | Wed, 07 Mar 2001 14:48:05 +0000 |
| Subject: | RE: Value of if(isset(X)) problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-42905@lists.php.net to get a copy of this message | ||
I think you'll find that cmdFinish is only passed through if the form is
submitted by pressing the button. Hitting return on any other field will
submit the form without sending cmdFinish. It might be sfare to check if one
of your text fields is set.
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -----Original Message-----
> From: Martin Skjöldebrand [mailto:chimbis@skjoldebrand.org]
> Sent: 07 March 2001 05:34
> To: php-general@lists.php.net
> Subject: Value of if(isset(X)) problem
>
>
> Sorry bout the length .... I'm a newbie to PHP/MySQL so bare
> with me ...
> Here's a snippet of an app I'm hacking. I have a form that
> should update a
> client form. the cl_XXXX are taken from a database table and
> works nicely.
> The point of this that they should possibly be replaced by
> txtXXX and put
> back in the table.
>
> As far as I can tell this _should_ work but it doesn't. I
> suspect that
> cmdFinish is never set if (isset($cmdFinish)) isn't true ....
>
> Any suggestions?
>
> 8< ------------- code -------------------------->8
>
> <tr>
> <td width="50%" valign=center align=right>Computer ID:
> </td>
> <td width="50%">
> <input type=text name="txtCompID" size=10 value = "<?echo
> $cl_compID?>">
> </td>
> </tr>
> <tr>
> <td width="50%" valign=center align=right>
> <font size=3>Email:</font>
> </td>
> <td width="50%">
> <input type=text name="txtEmail" size=20 value = "<?echo
> $cl_email?>">
> </td>
> </tr>
> </table>
> <p align=center>
> <center>
> <input type="submit" value="Modify client"
> name="cmdFinish">
> </td>
> </center>
> </tr>
> </table>
> </center>
> </div>
> </form>
>
> <?php //OK we can commit our changes ...
> if (isset($cmdFinish)) {
> $query = "UPDATE client SET ";
> $query .= "cl_login ='$txtLogin', ";
> $query .= "cl_firstname ='$txtFirstname', ";
> $query .= "cl_secondname ='$txtSecondname', ";
> $query .= "cl_phone = '$txtPhone', ";
> $query .= "cl_type = '$txtType', ";
> $query .= "cl_dept = '$txtDept', ";
> $query .= "cl_compID = '$txtCompID', ";
> $query .= "cl_email = '$txtEmail' ";
> $query .= "WHERE cl_login = '$lstModifyClient';";
> $mysql_result = mysql_query($query, $mysql_link);
> print "<CENTER><BR><BR>\n";
> print "$txtLogin has been successfully
> modified!<BR><BR></CENTER>\n";
> exit;
> }
>
> ?>
>
> <? }
> else {
> print "<CENTER><BR><BR><B>The Client:
> </B>$lstModifyClient has ";
> print "<b>not</b> been modified<BR></CENTER>\n";
> }
> }
>
> ?>
>