|
Posted by Art on 05/05/07 19:03
Geoff, I'm just trying to have validation in my form. I check to see if
certain fields have values, if all the required fields have values, i want
to sent the data to another php form, that processes the request and sends
the data to a sql database and generates an email that a request has come
in.
The problem i'm having is that no matter what i do, the form will not submit
on the first click, even though all conditions are met. I've tested this by
echoing variables that let me know where i am in the code.
What's strange is that when i hit the submit button the 2nd time, it submits
ok.
I've tried your suggestions but the abscense of the form tag in the html
deactivated the submit button. I'm going to try the other suggestion.
You're also right in that it can no doubt be done better. I'm new to php
programming. I'm currently enrolled in a cis programming degreed course but
haven't gotten into my core curricula yet.
Thanks for your patience
Art
"Rami Elomaa" <rami.elomaa@gmail.com> wrote in message
news:f1hgeu$9b2$1@nyytiset.pp.htv.fi...
> Geoff Berrow kirjoitti:
>> Message-ID: <DXN_h.24026$XU4.14377@bignews8.bellsouth.net> from Art
>> contained the following:
>>
>>> Geoff, I tried modifying the code with your suggestions. It had the
>>> effect of disabling the submit button. It seems like there has to be
>>> <form method="POST" action=""> in the html, to enable the submit button.
>>> Variables aren't being recognized by the html as defining the form.
>>
>> I was in a hurry last night because I was going out and not really
>> paying attention. Your code /is/ still seriously screwed but that
>> wasn't the solution.
>>
>> Can you please describe what you /expect/ it to do? I'm sure the answer
>> is very simple.
>>
>
> Your sample was missing the default form. It only worked in the case when
> something was posted, but in the case the page is opened the first time,
> there is no form tag at all...
>
> So, once again, from the top...
>
> <?php
>
> $holdchk = 0;
> if (isset($_POST['B1'])) { // if the form was submitted
> $form= "<br><br><br>";
> if (empty($_POST['app_fname'])) {
> $holdchk = 1;
> }
>
> if ($holdchk === 1 ){
> $form.= "<form method='POST' action='some.php'>";
> }
>
> if ($holdchk === 0 ){
> $form.= "<form method='POST' action='other.php'>";
>
> }
> } else { // no form was submitted
> $form = "<form method='POST' action='{$_SERVER['PHP_SELF']}'>";
> }
> ?>
>
> <html>
>
> <head>
> </head>
>
> <?php echo $form;?>
>
> When
> hit the submit button</font></b> <input
> type="submit" value="Submit" name="B1"></p>
> </form>
> </body>
>
> </html>
>
> I think this is what Geoff meant, he just forgot the default case. :)
>
> --
> Rami.Elomaa@gmail.com
>
> "Wikipedia on vδhδn niinq internetin raamattu, kukaan ei pohjimmiltaan
> usko siihen ja kukaan ei tiedδ mikδ pitδδ paikkansa." -- z00ze
Navigation:
[Reply to this message]
|