Forum Moderators: coopster

Message Too Old, No Replies

Modifying form output

suppress submit button on form output

         

Tourex

9:33 am on May 1, 2004 (gmt 0)

10+ Year Member



I'm using FormMail for the first time. It seems to be working OK, but the email form notification ends with the line "Submit: submit" - obviously taking this from the Submit button at the bottom of the form. How can I prevent this showing on the email? It’s so unnecessary and unprofessional-looking. I can't believe it's intentional, so assume I’ve set something up incorrectly.

Any help would be much appreciated. Its only a little thing, but its driving me nuts.

Birdman

11:15 am on May 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think those formmail scripts are meant to print all inputed values.

You'll need to look at the script and find the main loop that prints the form input vars. It'll probably be a foreach($_POST as $key => $val) loop.

Inside the loop, BEFORE the print statement, you need to add a line that goes like this:

if ($key == "Submit") continue;

That will make it skip over that iteration in the loop. Just make sure the var name matches what they are already using.

Birdman

Tourex

1:55 pm on May 1, 2004 (gmt 0)

10+ Year Member



Thanks Birdman

I confess that I'm not a coder so struggling a little here. I'm using the NMS FormMail v3.12c - but open to suggestions for any better/more secure/easier to modify script.

I can't find the string you mentioned, but have found the following. I don't know if this help you to help me:

Outputs the form fields to the email body.

=cut

sub send_main_email_fields {
my ($self) = @_;

foreach my $f (@{ $self->{Field_Order} }) {
my $val = (defined $self->{Form}{$f}? $self->{Form}{$f} : '');

$self->send_main_email_field($f, $val);
}
}

=item send_main_email_field ( NAME, VALUE )

Birdman

11:53 am on May 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello again,

That's Perl code, which I am still learning. I will take a shot at it though. Be sure to save a copy of the original before editing.

sub send_main_email_fields {
my ($self) = @_;

foreach my $f (@{ $self->{Field_Order} }) {
if ($self->{Form}{$f} == 'Submit'){
my $val = (defined $self->{Form}{$f}? $self->{Form}{$f} : '');
}

$self->send_main_email_field($f, $val);
}
}

If that doesn't work, try posting in the Perl forum and you'll get an answer quickly I imagine.

Birdman

Tourex

12:33 pm on May 2, 2004 (gmt 0)

10+ Year Member



Thanks Birdman, but sadly no joy - it just caused a "server" error.

Which is the PHP forum - I thought this was it?

Cheers

Tourex

6:18 pm on May 2, 2004 (gmt 0)

10+ Year Member



Ooops! Sorry, I don't know my Perl from my PHP.

Jon_King

6:50 pm on May 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this:

You probably have a submit button line like this:

<INPUT name="Input" type=submit value="Send Request">

remove the field name: name="Input"

to leave this:
<INPUT type=submit value="Send Request">

It works because without the field name it won't be included in the resulting email!

Jon

WhosAWhata

8:14 pm on May 2, 2004 (gmt 0)

10+ Year Member



as an alternative to changing you form processing code, you can change your form like this

you have something like


<form name="myform" method="post" action="formmail.pl">
<input type="text" name="textbox">
<input type="submit" name="Submit" value="submit">
</form>

if you move the submit button outside of the form, it will not send any data from the button "Submit:submit"


<form name="myform" method="post" action="formmail.pl">
<input type="text" name="textbox">
</form>
<input type="button" name="Submit" value="submit" onclick="document.myform.submit()">

Tourex

9:24 pm on May 2, 2004 (gmt 0)

10+ Year Member



I've tried that, but when I press "Submit", nothing happens. The screen stays the same and I certainly don't receive the email notifying me of the form contents.

WhosAWhata

4:08 am on May 3, 2004 (gmt 0)

10+ Year Member



dont forget the name though

<form name="myform" action="formmail.php" method=post>...
<input type="button" name="Submit" value="submit" onclick="document.myform.submit()">

other than that i don't know, it should work