Forum Moderators: open

Message Too Old, No Replies

Adding fields together to form email addresses

can anyone help?

         

lcann

2:17 pm on Feb 28, 2007 (gmt 0)

10+ Year Member



Hi,

I'm trying to put together a form where there are two email addresses. the first one will always be the same and so I would obviously use the action="mailto:name@test.com". The second however will be entered by the person who is filling in the form.

for example the user would fill in a field called name. I then need name adding to the second part of an email address and then the form is sent to both. so it would be "name"+"@test.com".

I assume I would have a text field called "name" and a hidden field with a value of "@test.com", but i'm struggling on how to add them together and post it along with the address that remains the same.

If any one can help that would be brill.

cheers,

LC.

music_man

11:32 pm on Mar 3, 2007 (gmt 0)

10+ Year Member



Hi

I think if you are adding them together you may need to either use javascript or php.

If you were using php, it would be something like:


<?php

if(isset($_POST['submit'])) // If the form is submitted
{
$ext = "test.com";
$name = $_POST['name'];

$to = $name.'@'.$ext; // Make a nice string :)

$subject = "Hi"

$content = 'Hi there, '.$name;

/* Now mail them. Look up [au3.php.net...] for headers you can send
*/

mail($to,$subject,$content);

header("Location: yourpage.php?msg=thanks!"); // Take them back to page

}

?>

<form method="post" action="yourpage.php">
<?php if(isset($_GET['msg'])) {
echo '<div>'.$_GET['msg'].'</div>';
} else {
?>
<div>
<label for="name">Name</label>
<input type="text" id="name" name="name" />
<br />
<input type="submit" name="submit" id="submit" />
</div>
</form>
<?php }?>

Probably has some parse errors :P