Script for form to email??

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Watch

JH

Established Member
Impact
5
hi,

dose anyone know a script to place on my site that will send form information to my email???
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
check hotscripts.com, sourceforge.net, freshmeat.net
 
0
Close
PHP:
<? 

mail ("email here", "$subject","$message");

?>
 
0
Close
0
Close
cheers i will have a look
 
0
Close
I can program you one if you wish.

CyberSpatium said:
check hotscripts.com, sourceforge.net, freshmeat.net

That is correct. These sites are preferable!
 
0
Close
i say hotscripts.com is your best choice i got mines from there last time
 
0
Close
its really easy...i can make 1 for u if u want
 
0
Close
Come up with one on the spot :P

PHP:
<?php

echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>
Name:
<br>
<input type='text' name='name'>
<br>
E-mail:
<br>
<input type='text' name='email'>
<br>
Message:
<br>
<textarea name='message' rows='10' cols='40'></textarea>
<br>
<br>
<input type='submit' name='submit' value='Submit'>
</form>";

if($_POST['submit'])
{
  $name = $_POST['name'];
  $email = $_POST['email'];
  $message = $_POST['message'];
  
  if(empty($name) || empty($email) || empty($message))
  {
    echo "All fields required. Please enter all information and try again.";
  }
  else
  {
    $name = stripslashes($name);
    $message = trim(stripslashes($message));
    $message = wordwrap($message, 70, "<br>\n");

    $recip = "[email protected]";
    $subject = "Message from yoursite.com";

    $headers = 'From: '.$email.'';

    mail("$recip", "$subject","

    Name:
    $name

    Email:
    $email

    Message:
    $message

  ", $headers);
  
  if(!mail)
  {
    echo "Seems to have been a problem, your message could not be sent, please try again later."
  }
  else
  {
    echo "Thank you, ".$name." for contacting us.";
  }
}
?>

:) It can be customized as well. If you require more data etc, should be easy to add the fields, etc...

-Eric
 
0
Close
Eric, if I just edited the email address and saved that code as contact.php, should it work as is? Or do I need to do something more? I tried it as is and get a 'Parse error line 57'.
 
0
Close
Gene said:
Eric, if I just edited the email address and saved that code as contact.php, should it work as is? Or do I need to do something more? I tried it as is and get a 'Parse error line 57'.
Yes, should work as is, and for the parse error (stupid me) missing a ; on this line:

PHP:
echo "Seems to have been a problem, your message could not be sent, please try again later."

And it should be:

PHP:
echo "Seems to have been a problem, your message could not be sent, please try again later.";
 
0
Close
Hmm, now getting parse error on line 63 (last line).
 
0
Close
Grrr, I need some sleep:

PHP:
<?php

echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>
Name:
<br>
<input type='text' name='name'>
<br>
E-mail:
<br>
<input type='text' name='email'>
<br>
Message:
<br>
<textarea name='message' rows='10' cols='40'></textarea>
<br>
<br>
<input type='submit' name='submit' value='Submit'>
</form>";

if($_POST['submit'])
{
  $name = $_POST['name'];
  $email = $_POST['email'];
  $message = $_POST['message'];
  
  if(empty($name) || empty($email) || empty($message))
  {
    echo "All fields required. Please enter all information and try again.";
  }
  else
  {
    $name = stripslashes($name);
    $message = trim(stripslashes($message));
    $message = wordwrap($message, 70, "<br>\n");

    $recip = "[email protected]";
    $subject = "Message from yoursite.com";

    $headers = 'From: '.$email.'';

    mail("$recip", "$subject","

    Name:
    $name

    Email:
    $email

    Message:
    $message

  ", $headers);
  
  if(!mail)
  {
    echo "Seems to have been a problem, your message could not be sent, please try again later.";
  }
  else
  {
    echo "Thank you, ".$name." for contacting us.";
  }
}
}
?>
 
0
Close
BINGO! Works like a charm. Thank you!
 
0
Close
Gene said:
BINGO! Works like a charm. Thank you!
No problem :) And like I said, it can easily be customized for more fields and what not. If you need any added (anyone) let me know and I'll add them. :tu:
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

A browser tab with a favicon next to the page title
Search members
You can now search for members by name, company, location and more. Open the search at the top of any page and choose Members. You will...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back