Im helpin a friend out with his website, a form but the submit button is giving me major problems, when i hit it, it emails be name=B1, and now im praying one of you guys can help me out with this

<FORM ACTION="mailto:harry.baynes@ntlworld.com" METHOD=POST TARGET=code ENCTYPE=text/plain>            
<input type="submit" value="Submit" name="Form">
<input type="reset" value="Reset" name="B2">
</form>

please help!
Hazor

Dani AI

Generated

Quick diagnosis: the form is using a mailto ACTION and the only submitted controls are the form buttons, so the mail client is packing the clicked control's name/value into the message (hence the mysterious "name=B1" line). Browsers and mail clients handle POST-to-mailto inconsistently; RFC 2368 and practical guidance recommend against relying on mailto for form processing (RFC 2368, MDN: Sending and retrieving form data).

Immediate troubleshooting steps that are safe and quick:

  • Remove the name attribute from the submit/reset controls so the button's name/value is not included in the encoded payload.
  • Add real named input fields (for example name="email" and name="message") so the email body contains user data rather than just the button.
  • Prefer a server-side endpoint rather than mailto; this avoids client-dependent behavior entirely.

A recommended, robust approach is to POST to a server script and send the mail from the server. Example HTML + PHP flow (replace addresses and harden input handling before use):

<form action="process.php" method="post">
  <input type="email" name="email" required>
  <textarea name="message" required></textarea>
  <button type="submit">Send</button>
</form>
<?php
// process.php (minimal example — validate and sanitize in real code)
$to = 'harry.baynes@ntlworld.com';
$subject = 'Contact form';
$body = '';
foreach ($_POST as $k => $v) { $body .= "$k: $v\n"; }
$headers = "From: webmaster@example.com\r\n";
mail($to, $subject, $body, $headers);
?>

Security and reliability notes: sanitize all inputs and protect against email header injection (). As observed, resets usually need no name; that helps. As noted, naming elements is useful for JavaScript — keep an id for JS if the submit button must be referenced, but avoid giving the button a name when using mailto. Server-side handling or a form-backend service is the long-term fix.

Recommended Answers

All 2 Replies

Im helpin a friend out with his website, a form but the submit button is giving me major problems, when i hit it, it emails be name=B1, and now im praying one of you guys can help me out with this

<FORM ACTION="mailto:harry.baynes@ntlworld.com" METHOD=POST TARGET=code ENCTYPE=text/plain>            
<input type="submit" value="Submit" name="Form">
<input type="reset" value="Reset" name="B2">
</form>

please help!
Hazor

--------------------------
Not sure if this will help or not, but the following is what I typically do. I have never tried include a 'name' for the reset key before.

<INPUT TYPE="submit" NAME="Submit" VALUE="Submit">
<INPUT TYPE="reset" VALUE="Reset">

Maybe?
ctkr

You should be able to assign a name to any html element as far as I know. For example, I would name an object for the sole purpose of being able to attach some JavaScript event to it.

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.