I am wanting to create a form for a website that people fill in the required fields and then click subnit. When the person clicks submit I would like for the info to be sent to an email address. I know it is probably pretty simple, but I am new to all of this. So if someone could get me moving in the right direction I would greatly appreciate it.

Dani AI

Generated

For : the most reliable way to get form data emailed in the exact order you want is a small server-side handler that (1) accepts the POSTed form, (2) validates and sanitizes each field, (3) builds the message using the fields in a fixed sequence, and (4) optionally appends the same values to a CSV for easy import into your other program. and mention quick client-side and host-provided options — those are fine for testing, but a server-side script gives predictable formatting and better control.

Practical workflow to implement:

  • Give each input a clear name that matches the column order you want.
  • Use client-side validation for user convenience, but always validate on the server.
  • Build the email body by iterating a fixed array of field names so output order never changes.
  • Save a CSV row at the same time so you have a machine-friendly record.

Example PHP sketch (sanitize inputs and adjust names to match your form):

<?php
$fields = ['firstname','lastname','email','phone'];
$message = "";
foreach ($fields as $f) {
  $v = isset($_POST[$f]) ? trim($_POST[$f]) : '';
  $message .= ucfirst($f) . ': ' . $v . "\r\n";
}
$reply = filter_var($_POST['email'] ?? '', FILTER_VALIDATE_EMAIL) ?: 'no-reply@yourdomain.com';
$headers = "From: no-reply@yourdomain.com\r\nReply-To: $reply\r\n";
mail('recipient@yourdomain.com', 'Form submission', $message, $headers);
?>

To keep a CSV copy (safe for import):

<?php
$fp = fopen(__DIR__ . '/submissions.csv', 'a');
if ($fp) {
  $row = [];
  foreach ($fields as $f) $row[] = $_POST[$f] ?? '';
  fputcsv($fp, $row);
  fclose($fp);
}
?>

Quick cautions: store CSV outside the webroot or protect it, set file permissions, prevent email-header injection (strip CR/LF in headers), and test on the live host (local dev often has no mail). If your host blocks mail(), use authenticated SMTP (libraries like PHPMailer) so messages reliably arrive and avoid spam filters.

Recommended Answers

All 4 Replies

Hi, can you provide a little more information? is it a basic HTML form you are wishing to create? or is it using php or even aspx?

for a simple HTML form try:

[form action="mailto:"
method="post"]
First name:
[input type="text" name="firstname"]
[br]
Last name:
[input type="text" name="lastname"]
[input type="submit" value="Submit"]
[/form]for the required fields try looking up some simple javascript to vaildate the form fileds the submit button is pressed.

Regards.

Your Web host probably has a mail script already installed on their server for you to use. Most give you some documentation on how to use it as well.

After the person puts in the info to the form and click submit. Then I want that info to go to an email in the same order as the Form. From their I will enter the information in another program. I just need a more organized manner of receiving the info.
Thanks for the help

I like the all-in-one form handler from bignosebird.com.

It will do exactly what you are asking for here...and it is free.

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.