i was just wondering how do u make a form that when the person using it will hit submit and the info will be sent to my email or to me somehow

everytime i try it doesnt do nething, and i cant find a tutorial on this

i need to do this for a survey i will be making for my friends to take for my final exam that is in 2 weeks

Dani AI

Generated

Quick summary for : the HTML form itself only gathers data — the recipient address goes in the server-side mail handler, not in the form HTML. As suggested, you need a dynamic page on a server that can run the script. Given your two-week deadline, either use a hosted form service (fast, no server setup) or put a small handler on a test host/ local server and upload the files from Dreamweaver.

Example of where to put the email address (not present in the thread):

Classic ASP (CDO)
<%
Set msg = CreateObject("CDO.Message")
msg.To = "you@yourdomain.com"
msg.From = "webmaster@yourdomain.com"
msg.Subject = Request.Form("subject")
msg.TextBody = Request.Form("message")
msg.Send
Set msg = Nothing
%>
PHP (simple)
<?php
$to = 'you@yourdomain.com';
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = 'From: webmaster@yourdomain.com' . "\r\n";
mail($to, $subject, $message, $headers);
?>

Notes: the To/$to values are where your email address goes; Set ... = Nothing (ASP) is cleanup and must come after Send. Always validate/sanitize input to avoid header injection. If PHP mail() or ASP send fails on a host, use a library that supports SMTP authentication (PHPMailer for PHP) or check the host SMTP settings.

Quick troubleshooting checklist for and others who saw errors:

  • Make sure files are run through a web server (not file://). Use XAMPP/WAMP or your host.
  • Turn on error reporting so the server shows the failing line, or check server error logs.
  • Confirm form action points to the handler and field names match.
  • If mail silently fails, try authenticated SMTP (PHPMailer) or consult the host about mail restrictions.

References: MDN on form handling (https://developer.mozilla.org/en-US/docs/Learn/Forms/Sending_and_retrieving_form_data), PHP mail() docs (https://www.php.net/manual/en/function.mail.php), PHPMailer (https://github.com/PHPMailer/PHPMailer), XAMPP (https://www.apachefriends.org/index.html).

Recommended Answers

All 4 Replies

You must to use either server script languages such as ASP/PHP

here is a PHP example http://www.tutorialguide.net/php_contact_form_tutorial.html
here is a ASP example
http://www.tizag.com/aspTutorial/aspFormsEmail.php

or you can use just form with target mailto to force send the email in Outlook, but server side scripting is better.

<form enctype="text/plain" method="get" action="mailto:info@info.com">
To <input type="text" name="To"/> <br />
Subject <input type="text" name="Subject"/> <br />
Body <textarea name="Body" rows="5" cols="20" wrap="physical" > 
</textarea>
<input type="submit" />
</form>

ok thx im going to use the .asp one but im curious because this tutorial does not exactly state were i should be making my email adress

would it be after the set mail = nothing?

I used the php code small dog linked too but it didn't work it said error on line 24 and I dont know php so I left it,

easiest way would be the mailto: command. find it in behaviors i believe

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.