The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Getting a webform to send an email, (my html is really, really, rusty)
Drahnyn
post Oct 21 2021, 08:52 AM
Post #1





Group: Members
Posts: 7
Joined: 21-October 21
Member No.: 28,151



Hey folks. It's been about ten years since I've needed to write any html, I'm sorely out of practice and I cannot find the answers I'm looking for online (either that, or I found them and they're not making sense...)

I have to make a simple form, multiple pictures with a text box beneath for each picture (for the user to write descriptions) and then a submit button at the bottom of the page to send me their texts. The last time I wrote html was pre-https, but I've already changed my whole domain to https (it was not fun figuring that out).

What I've got so far is this:

<form action="mailto:email@address" method="post" enctype="text/plain" name="Info about those pictures" autocomplete="off">
Picture one:<input type="text" name="Picture one">
<br><br>
Name:<input type="text" name="name"><br><br>
E-mail:<input type="text" name="mail"><br><br>
<input type="reset" value="Reset">
<input type="submit" value="send info" name="submit">
</form>

[[note that this is just a basic sample of the relevant html, I didn't see a point to putting the entire length of it]]

From doing some reading, I'm not sure if I should be using the input tag for Picture one, or I should be using the textarea tag like this
<Textarea Wrap=Physical Name="Picture one" Cols=30 Rows=1></Textarea>

Either way, I have tried both, individually and together, and cannot get either of them to work. I've been working on this for two days and I cannot get the page to send an email.

Just to add, I've got all the links in the html pointing to https, and I'm still getting "The form is not secure. Autofill has been turned off." even though I have the autocomplete=off. Then, when the send info button is clicked the next page says "The information you’re about to submit is not secure" and when the send anyway button is clicked nothing happens. On that page, in the address bar, is what looks like the email that should be sent. It starts with "mailto:email@address?body=" and has %20 where all the spaces should be. My word processor program shows that the text is just over two full pages and almost ten thousand characters (all in the address bar).

I'm probably (typically) missing something simple to get the email to send, but I (obviously) cannot figure it out.

Any useful advice would be awesome!

This post has been edited by Drahnyn: Oct 21 2021, 08:53 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Oct 21 2021, 04:12 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



Forms using action=mailto are unreliable, since they won't work for users depending on webmail services. At a minimum, the user needs a supporting email program installed on his own computer. Maybe that also explains the security warning (assuming the mailto protocol is unencrypted)? See also https://htmlhelp.com/faq/html/all.html#mailto-form

QUOTE
I'm not sure if I should be using the input tag for Picture one, or I should be using the textarea tag

An INPUT text field only lets the user type a single line, while a TEXTAREA element also allows linebreaks, and lets the user view more text.

As for the space in the NAME value:

QUOTE
CODE
<input type="text" name="Picture one">

I don't know if it's allowed --I'd guess not, but HTML5 seems lenient:

3.2.4.1 Attributes

An attribute value is a string. Except where otherwise specified, attribute values on HTML elements may be any string value, including the empty string, and there is no restriction on what text can be specified in such attribute values.
https://html.spec.whatwg.org/multipage/dom....#attribute-text

unsure.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 21 2021, 04:14 PM
Post #3


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



I don't understand what exactly goes wrong and when. When you hit the submit button? What happens? The snip you posted works for me.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Drahnyn
post Oct 21 2021, 04:55 PM
Post #4





Group: Members
Posts: 7
Joined: 21-October 21
Member No.: 28,151



I've got a feeling that the issue is stemming from my server have FormMail Version 1.92, last updated April 2002, on it.

That said, I've already changed the code to this
<form action="/cgi-bin/formmail/formmail.pl" value="email@address" name="Info about those pictures" method="post" enctype="text/plain" autocomplete="off" enctype="multipart/form-data">

I've gotten rid of all the security warnings. but I'm stuck at a Error: Bad/No Recipient message from /cgi-bin/formmail/formmail.pl
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 21 2021, 05:08 PM
Post #5


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



That can't have been the problem when you used mailto. No script or anything else would have been involved. Mailto just open the email client, if there is one, and passes the field values to it.

I'm still wondering exactly how the form didn't work when you used mailto.

formmail.pl shouldn't be used at all. it's old and it isn't secure.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Drahnyn
post Oct 21 2021, 06:11 PM
Post #6





Group: Members
Posts: 7
Joined: 21-October 21
Member No.: 28,151



If my original code worked, could my actually having the formmail.pl in the cgi-bin folder be causing the conflict?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 21 2021, 06:18 PM
Post #7


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



When you used mailto? No. Why don't you tell us what this conflict was, how it manifested itself? This is turning more and more into mystery meat.

Anyway, do NOT use Matt's formmail script. You could end up in a whole lot more serious trouble than you have now. I got the impression your host provides that script. If they do, they don't know what they are doing.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Drahnyn
post Oct 21 2021, 10:27 PM
Post #8





Group: Members
Posts: 7
Joined: 21-October 21
Member No.: 28,151



So it seems the issues were from the tags from the bottom of the code, the send button section. Once I changed that whole section the security error vanished, the formmail error vanished, and it looked like the email was sent. Of course I didn't get any email, but it looked good tongue.gif

This is the current code
<form action="/cgi-bin/formmail/formmail.pl" method="POST">
<input type="hidden" name="redirect" value="https://blahblah/thanks.html">
<input type="hidden" name="recipient" value="email@address">
<input type="hidden" name="subject" value="Pictures info">

Your name:<br>
<input name="name" size=30 maxlength="30">
<br>
e-mail address: <br>
<input name="email" size=30 maxlength="30">
<br>
Message/comments:<br>
<textarea wrap=physical name="Message/comments" cols=30 rows=8></textarea>
<br>
<br>
<input type="submit" value="send email" name="submit">
<input type="reset" value="clear" name="reset">
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Drahnyn
post Oct 22 2021, 12:32 AM
Post #9





Group: Members
Posts: 7
Joined: 21-October 21
Member No.: 28,151



My web hosting support sent me this:

The formmail script you are using is very old and doesn't offer any spam protection. This may allow bad actors to send thousands of spam messages to your mailbox. We would recommend switching to a more modern contact form script that offers spam protection, such as CAPTCHA.

We don't have a ready-made script that you can install, unfortunately. We cannot recommend a particular script, either.


Since the formmail was the only thing in that cgi-bin folder, I simply renamed that folder making the formmail inaccessible.

I've since written some php's for the form input to use, but as yet still cannot get any code to send an email.

They have a Website Builder, all pictures and components, which they recommended I try, but I've been writing everything myself in code, line by line, since the 90's (ignoring the hiatus) and those builders just confuse the heck out of me.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Oct 22 2021, 06:14 AM
Post #10


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,716
Joined: 9-August 06
Member No.: 6



I tried to tell you, but you don't listen much, do you? Or answer questions. Furthermore, the big problem isn't that spammer could send spam to YOUR inbox. It's that they can use your server to send spam to other people. Which may cause your server to be blocked and there could also be legal issues.

Just delete the crap. If you want to keep it just for fun, save it on your hard drive.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Drahnyn
post Oct 22 2021, 07:57 AM
Post #11





Group: Members
Posts: 7
Joined: 21-October 21
Member No.: 28,151



QUOTE(pandy @ Oct 22 2021, 07:14 AM) *

I tried to tell you, but you don't listen much


It's not that I didn't listen. I actually said to my support what you had said and they agreed and further explained, which is what I shared. Just because you read it on the internet doesn't make it true, right? biggrin.gif It was nice to get a confirmation.

Plus, I'm still frustrated I cannot get any of the frelling attempts to work, no matter the direction I'm coming at it from. I know I should have had this done by now.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Drahnyn
post Oct 22 2021, 12:00 PM
Post #12





Group: Members
Posts: 7
Joined: 21-October 21
Member No.: 28,151



I'm simplifying things until I get this figured out. My entire html is this

<form method="post" class="myform" action="process-form.php">
<input type="text" name="name" placeholder="Your Name" required><br>
<input type="email" name="email" placeholder="Your Email" required><br>
<textarea rows="4" cols="20" name="message" placeholder="Your Message"></textarea><br>
<input type="submit" name="send" value="Send"> <span class="output_message"></span>
</form>

The jQuery.js is

$(document).ready(function() {
$('.myform').on('submit',function(){

// Add text 'loading...' right after clicking on the submit button.
$('.output_message').text('Loading...');

var form = $(this);
$.ajax({
url: form.attr('action'),
method: form.attr('method'),
data: form.serialize(),
success: function(result){
if (result == 'success'){
$('.output_message').text('Message Sent!');
} else {
$('.output_message').text('Error Sending email!');
}
}
});

// Prevents default submission of the form after clicking on the submit button.
return false;
});
});


The process-form.php is

if (isset($_REQUEST['name'],$_REQUEST['email'])) {

$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];

// Set your email address where you want to receive emails.
$to = 'email@address';

$subject = 'Contact Request From Website';
$headers = "From: ".$name." <".$email."> \r\n";

$send_email = mail($to,$subject,$message,$headers);

echo ($send_email) ? 'success' : 'error';

}

When I go to that html and enter John Doe, john@aol.com, AOL is old, and click Send, this is what the next page shows
if (isset($_REQUEST['name'],$_REQUEST['email'])) { $name = $_REQUEST['name']; $email = $_REQUEST['email']; $message = $_REQUEST['message']; // Set your email address where you want to receive emails. $to = 'email@address'; $subject = 'Contact Request From Website'; $headers = "From: ".$name." <".$email."> \r\n"; $send_email = mail($to,$subject,$message,$headers); echo ($send_email) ? 'success' : 'error'; }

I think I'm missing a call, somewhere, to something like jquery-3.4.1.min.js but I cannot figure out how that's done.



Then I created this tiny html
<!DOCTYPE html>
<html>
<body>
<h2>Give Feedback to Our Website.</h2>
<form action="mailto:email@address" method="get" enctype="text/plain" autocomplete="off">
<div>
<label for="name">Name:
<input type="text" name="name" id="name" />
</label>
</div>
<div>
<label for="email">Email:
<input type="text" name="email" id="email" />
</label>
</div>
<div>
<label>Comments:</label>
<br />
<textarea name="comments" rows="12" cols="35"></textarea>
</div>
<div>
<input type="submit" name="submit" value="Send" />
<input type="reset" name="reset" value="Clear Form" />
</div>
</form>
</body>
</html>

and with that I'm getting the security warnings again.

Wherever I have "email@address" I do actually have an actual email address, from the domain that these pages live.

All these files are in the root www folder in my server.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 28th March 2024 - 10:48 AM