Form Submission/Mail To Script

Links for php scripts

Moderators: macek, egami, gesf

xiaoaiz1865
New php-forum User
New php-forum User
Posts: 8
Joined: Thu Nov 25, 2004 11:52 am
Contact:

Form Submission/Mail To Script

Postby xiaoaiz1865 » Thu Nov 25, 2004 12:17 pm

Here it is.
form.php

Code: Select all

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form action="mailit.php" method="post" name="frmEmail" id="frmEmail">
  Name:
  <input name="name" type="text" id="name">
  <br>
  E-mail:
  <input name="email" type="text" id="email">
  <br>
  Message:<br>
  <textarea name="message" id="message"></textarea>
  <br>
  <input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>


mailit.php

Code: Select all

<?php
sMessage = "Message from: " + $_GET['name'] +"<BR>";
sMessage .= "Email: <a href='mailto:" + $_GET['email'] + "'>" + $_GET['email'] + "</a>";
sMessage .= "Message was:" + $_GET['message'];
mail "mail@mail.com", "Contact Mail...", sMessage;
?>


Change mail@mail.com to your email address.

Alex
New php-forum User
New php-forum User
Posts: 180
Joined: Fri Mar 07, 2003 4:59 pm
Contact:

Postby Alex » Mon Nov 29, 2004 9:26 am

I dont want to upset you in any way, but there is room for improvement. For example, you could check the validity of the email adress (in part) via reg exp and allow for attatchments (i beleive i wrote a class for that a while back, but there is lots of documentation and examples out there). Its a good idea to put a from field in there too...


Return to “PHP Scripts”

Who is online

Users browsing this forum: Google [Bot] and 1 guest