Connecting Tech Pros Worldwide Forums | Help | Site Map

form problem

Krista
Guest
 
Posts: n/a
#1: Jul 17 '05
Hi , hope u guys can help me out ...

Can i do like that in php file?

<form....> (doesnt work)
<form....>
............ (doesnt work)
</form>
<form....> (work)
...............
</form>
..............
</form>
when i do it like that i can only work in one form action.
thanks,
krista

Daniel Tryba
Guest
 
Posts: n/a
#2: Jul 17 '05

re: form problem


Krista <ywan_ip@hotmail.com> wrote:[color=blue]
> Can i do like that in php file?
>
> <form....> (doesnt work)
> <form....>
> ............ (doesnt work)
> </form>
> <form....> (work)
> ...............
> </form>
> ..............
> </form>
> when i do it like that i can only work in one form action.[/color]

You can't nest forms, actions taken by the browser are irratic (most
process the first form, at least konqueror processes last).

BTW I don't see how this question is related to PHP! Looks like you are
asking a clientside question IMHO.

--

Daniel Tryba

Joshua Beall
Guest
 
Posts: n/a
#3: Jul 17 '05

re: form problem


"Krista" <ywan_ip@hotmail.com> wrote in message
news:eb97c972.0312231638.6dfd1921@posting.google.c om...[color=blue]
> Hi , hope u guys can help me out ...
>
> Can i do like that in php file?
>
> <form....> (doesnt work)
> <form....>
> ............ (doesnt work)
> </form>
> <form....> (work)
> ...............
> </form>
> ..............
> </form>
> when i do it like that i can only work in one form action.
> thanks,
> krista[/color]

I do not understand the question, what you are trying to do, or how PHP has
anything to with it. Perhaps if you could post some of the actual code that
you are having trouble with, or a link to an example page?


Pedro Graca
Guest
 
Posts: n/a
#4: Jul 17 '05

re: form problem


Krista wrote:[color=blue]
><form....> (doesnt work)
> <form....>
> ............ (doesnt work)
> </form>
> <form....> (work)
> ...............
> </form>
> ..............
></form>
> when i do it like that i can only work in one form action.[/color]


You can't have a <form ...> inside another <form ...>.

But you can have two different forms (with two different submit buttons)
on the same page :)

<form name="form1" action="processform.php" method="post">
<input type="hidden" name="formname" value="form1"/>
<input type="text" name="name"/>
<input type="submit"/>
</form>
<form name="form2" action="processform.php" method="post">
<input type="hidden" name="formname" value="form2"/>
<input type="text" name="address"/>
<input type="submit"/>
</form>


and your processform.php could be something like:

<?php // processform.php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// process form
if (isset($_POST['formname'])) {
if ($_POST['formname'] == 'form1') {
// deal with form1
// $_POST['name'] is (probably) ok
// $_POST['address'] is not defined here
} else {
// assume form2 and deal with it
// $_POST['name'] is not defined here
// $_POST['address'] is (probably) ok
}
} else exit('Go hacking someplace else!');
} else exit('You cannot GET (or HEAD, or ...) this page!');
?>
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Closed Thread