So, do not rely on BUTTONS as variables in scripts since browsers are FUNKY
and button variables don't always get set as they should. Use hidden
variables. If you have different buttons doing different things, such as
(delete, submit, open, etc.), then make each button call a javascript to set
the value of the hidden variable like so:

<form name="myForm" method="post" action="phpscript.php">

<input type="button" name="edit" onClick="javascript:
this.form.action.value='edit';">
<input type="button" name="delete" onClick="javascript:
this.form.action.value='delete';">
<input type="submit" name="Submit" onClick="javascript:
this.form.action.value='submit';">

<input type="hidden" name="action"> <!-- this value will be set by the
button that gets clicked by user -->
</form>

THis always works for me!

Nicole Amashta
www.aeontrek.com

==============================

"Nicole Amashta" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> AHA! That is it, and I've encountere this before.
>
> OK, actually $submit should be set. But do this instead:
>
> add a hidden tag to the form as such:
>
> =================
> <form method="post" action="registrer.php">
>
>  Fornavn: <input type="text" name="fornavn"><br>
>
>  Etternavn: <input type="text" name="etternavn"><br>
>
>  <input type="Submit" name="submit" value="Registrer">
>
> <input type="hidden" name="action" value="submit">
>
>  </form>
>
> =================
>
> Then, in your php script, do this:
>
> if ( $action == "submit" )
> {
>   ## do the action here ....
> }
> ================
>
>
> This is how I handle my forms. I use hidden tags with values that will
most
> certainly be passed to the script. If the submit button is not clicked,
that
> value doesn't get set, thus not showing up to the calling script. But, if
> you actually click the button, it will. If you are just hitting your
"enter"
> or "spacebar" to submit the form, then the $submit is never set.
>
> -Nicole Amashta
> www.aeontrek.com
>
> =============================
>
> "Court Shrock" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]...
> > > registrer.html ->
> > >
> > > <html>
> > > <head></head>
> > > <body><form method="post" action="registrer.php">
> > > Fornavn: <input type="text" name="fornavn"><br>
> > > Etternavn: <input type="text" name="etternavn"><br>
> > > <input type="Submit" name="submit" value="Registrer"><br> </form>
> >
> > I do not think that an input of type 'submit' will be submitted in the
> post
> > to the next page...you could verify this by doing a phpinfo at the top
of
> > registrer.php....the only name/value pairs submitted in the above form
> > should be "fornavn" and "etternavn".
> >
> > > </body>
> > > </html>
> > >
> > > registrer.php ->
> > >
> > > <?
> > > IF (isset($submit))
> >
> > ...and therefore, the above statement would fail because the $submit
> > variable is not set and therefore the intended code below would not be
> > executed....
> >
> > > {
> > > $hostname = "dbname";
> > > $username = "chris";
> > > $password = "*****";
> > > $dbname = "chris";
> > > MSSQL_CONNECT($hostname,$username,$password);
> > > mssql_select_db($dbname);
> > > $sql = "insert into studenter(fornavn, etternavn) values
> > > ('$fornavn','$etternavn')";
> > > $result = mssql_query($sql);
> > > $studentnummer = mssql_insert_id();
> > > Print("Studenten er lagt inn!");
> > > }
> > > ?>
>
>



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to