Re: Newbie - Form Submission Question

From: Date: Sun, 18 Aug 2002 21:35:49 +0000
Subject: Re: Newbie - Form Submission Question
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-15337@lists.php.net to get a copy of this message
Then wrote: Hi I've a FORM like this on addhome.html -- <FORM name="frmlogin" method="post" action="log_make.php"> User Name:<INPUT type="text" maxlength="10" name="username"> Password:<INPUT type="password" maxlength="10" name="password"><BR> <INPUT type="button" value="Login" name="butloginusr"> <INPUT type="button" value="Create User" name="butmakeusr"> </FORM> The idea is when the user clicks on the button "name=butloginusr" the next page prints Logged In User along with the values of the $username & $password OR when the user clicks button "name=butmakeusr" the next page prints Created User along with the values of the $username & $password. Both the clicks would be processed by log_make.php. * How can I make log_make.php recognise the button that was clicked i.e. Did the page viewer want to login or create a user? * Can I remove the attribute "action=log_make.php" and assign individual scripts to each of the buttons? When I tried this the server said I could not do a POST on address/addhome.html. /*************** My system config is as follows - OS: Win'98 PHP Version:4.2.2 (w/ Register Global Variables=On) Apache Version:1.3.26 Physical Directory of Files: C:\server\Apache\htdocs\address ****************/ Any help or suggestions would be greatly appreciated. Thanks theN Joachim Krebs wrote:
First of all let me scold you for running Apache and PHP on Windows 9x. The solution would be to make two inputs of type "submit" that have the same name but different values. Then when the form is submitted you check the variable $button_name and execute the relevant code. Hi
Much obliged for the prompt response. I changed the FORM according to your suggestion -- <FORM name="frmlogin" class="login" id="login" method="post" action="log_make.php"> User Name:<INPUT type="text" maxlength="10" tabindex="1" name="username" id="username"> Password:<INPUT type="password" maxlength="10" tabindex="2" name="password" id="password"><BR><BR> <INPUT type="submit" name="butusr" value="Login"> <INPUT type="submit" name="butusr" value="Create"> </FORM> and I coded log_make.php as follows /*BEGIN log_make.php*/ switch($butusr) { case "Login": echo("You Logged in with - ".$username ."&amp;". $password); break; case "Create": echo("Created User with - ".$username ."&amp;". $password); break; } /*END log_make.php*/ :-) It worked right the first time. With regards to my original post, could you kindly give your input on the following -- * Can I remove the attribute "action=log_make.php" and assign individual scripts to each of the buttons? When I tried this the server said I could not do a POST on address/addhome.html. Thanks and Regards theN

« previous php.windows (#15337) next »