name attribute in input tag

E

eggie

I was wondering is it possible to use the name attribute e.g. <input name =
"name" type = "text" etc.
in forms to let the user fill in an email address in a text field and the
form be sent to that address.

I tried <form action = "mailto:name" more in hope than expectation but
didn't get anywhere?

Is there a solution to this?
 
A

Adrienne


<form id="mailing" action="mailingscript" method="post">
<fieldset>
<legend>Your mailing information</legend>
<label for="yourname">Name: </label><input type="text" name="yourname"
id="yourname" value="">
<label for="email">Email: </label><input type="text" name="email"
id="email" value="">
<input type="submit" value="Submit">
</fieldset>
</form>

Upon submission of the form, name value pairs are posted to the processing
script. As you saw in your example, using mailto for action does not work
very well.

Check with your host to find out what the mailing script name is, and what
parameters it requires. If your host does not provide a form processing
script, you could use something like http://www.response-o-matic.com .
 
T

Toby A Inkster

eggie said:
I was wondering is it possible to use the name attribute e.g. <input name =
"name" type = "text" etc.
in forms to let the user fill in an email address in a text field and the
form be sent to that address.

Yes, but not in a way like you described.

You would need a server-side script to do this. For example with PHP...

form.html should contain:

<form action="handler.php" method="POST">
<p>
<input type="text" name="email"> E-mail (From)<br>
<input type="text" name="email2"> E-mail (To)<br>
<input type="text" name="subject"> Subject<br>
<input type="text" name="msg"> Short Message
</p>
<p>
<input type="submit">
</p>
</form>

and handler.php would consist of:

<?php
// specify a page to redirect to afterwards.
$redirect = 'http://www.example.org/thanks.html';

$hdrs = 'From: ' . $_POST['email'] . "\r\n"
. 'X-Originating-IP: ' . getenv('REMOTE_ADDR') . "\r\n"
. 'X-Mailer: PHP/' . phpversion();
$to = $_POST['email2'];
$subj = $_POST['subject'];
$msg = $_POST['msg'];

mail($to,$subj,$msg,$hdrs);
header("Location: $redirect");
?>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top