Jump to content

[SOLVED] SMALL problem with my input box


addtrain

Recommended Posts

I use FormMail.php, and it works GREAT!

 

Here's a sample form, with the appropriate action:

[pre]

<form name="form1" method="post" action="formmail.php">

<input name="recipient" type="hidden" value="[email protected]">

<input name="subject" type="hidden" value="Type your subject here">

<p>Name</p>

<input name="name" type="text" id="name">

<p>Email</p>

<input name="email" type="text" id="email">

<p>Comment/Question:</p>

<textarea name="comment" rows="6" id="comment"></textarea>

</form>

[/pre]

 

Note that it references "formmail.php" in the action. You just have to load formmail into the same directory as your form (or you can reference a path to it, of course), and change a couple of parameters in the formmail.php file, and it automatically processes ALL your form info. In formmail.php, you have to set the referrers - so people can't really use your formmail.php script for spamming. Then you're ready to go.

 

Here's a link to formmail.php:

 

http://www.dtheatre.com/scripts/formmail.php

 

Hope that helps!

 

Dan sends...

U can use the builtin php email gateway. Use a code like this:

 

<form id="form1" name="form1" method="post" action="">
  <input type="text" name="email" id="email" />
  <input type="submit" name="button" id="button" value="Submit" />
</form>

<?php
if(array_key_exists('data', $_POST)){
$data = $_POST['data'];
$to = "[email protected]";
$subject = "Email from your site";

$message = "This information has been submited to your website: \n\n";
$message .= $data;

$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "To: Your Name <$to>\n";
$headers .= "From: Your Site <[email protected]>\n";

if(@mail($to, $subject, $message, $headers)){
	echo "Your data was sent succesfully";
} else{
	echo "There was a problem sending your email. Plese retry later";
}

}
?>

 

If the post data is submited, the script will send u an email with that data. It involves simple error handling for the mail() function to determine if the email was sent. Replace the $to with your email and FROM in $headers with the sender email. Hope it helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.