|
chinesedoll (f)
|
Hi guys anybody here who can give me a code whereby if a form is submitted it goes to an email address instead of a database
It could be PHP C# OR ASP.NET.
i NEED IT URGENTLY.
|
|
|
|
|
|
|
|
IAH (f)
|
Google "php form emailer script" or "asp form emailer script". You’ll find free ones to lift. 
|
|
|
|
|
|
Zahymaka (m)
|
ruky_ivy, from a previous post of yours, I assume you're more comfortable with Asp.NET. I'm more inlined towards C# but I'll give you the code in both C# and VB. C# using System.Web.Mail; // the .NET mail namespace
MailMessage myMailMsg = new MailMessage(); myMailMsg.Subject = "Subject of Mail"; myMailMsg.To = "recipient@example.com"; myMailMsg.From = "sender@example.com"; // you can add myMailMsg.Cc and myMailMsg.Bcc myMailMsg.BodyFormat = MailFormat.Text; // can be either MailFormat.Text or MailFormat.HTML myMailMsg.Priority = MailPriority.Normal; //can be either MailPriority.High, MailPriority.Normal or MailPriority.Low myMailMsg.Body = "your body"; // you can append the body from a textbox eg myMailMsg.Body = txtComments.Text;
SmtpMail.Send(myMailMsg); // send message
VB Imports System.Web.Mail ' the .NET mail namespace
Dim myMailMsg as MailMessage = new MailMessage myMailMsg.Subject = "Subject of Mail" myMailMsg.To = "recipient@example.com" myMailMsg.From = "sender@example.com" 'you can add myMailMsg.Cc and myMailMsg.Bcc myMailMsg.BodyFormat = MailFormat.Text 'can be either MailFormat.Text or MailFormat.HTML myMailMsg.Priority = MailPriority.Normal 'can be either MailPriority.High, MailPriority.Normal or MailPriority.Low myMailMsg.Body = "your body" 'you can append the body from a textbox eg myMailMsg.Body = txtComments.Text
SmtpMail.Send(myMailMsg) 'send message
As you can see, the code is very similar. It's been long since I did anything Asp.NET but if you run into any snags [especially exceptions] you can always reply here.
|
|
|
|
|
|
smartsoft (m)
|
Step 1:: Make a page called contact.php and paste this code into it. <form action="contactme.php" mehod="post"> <p align="center"> <b><font size="2" face="Verdana">Name: <input type="text" name"username" size="30"/> <br> <br> Email: <input type="text" name="useraddr" size="30"> <br> <br> Message: <textarea name="comments" cols="30" rows="5"> </textarea> <br> <br> <input type="submit" value="Send Form"> </font></p> </form></b> Step 2:: Make a new page and paste the code below into it and name it contactme.php <?PHP #Where you want the email to go $to = "Youremail@yoursite.com";
#subject of the message, change this $re = "Feedbackfromcontactpage";
#message from the feedback form, don't touch this $msg = $comments;
#send the mail, don't edit this mail($to,$re,$msg); header("location: thankyou.htm"); ?>
|
|
|
|
|
|
Zahymaka (m)
|
smartsoft, I'm sure you didn't mean to make a mistake but using $comments instead of $_POST['comments'] in PHP only works if register_globals is turned to On.
|
|
|
|
|
|
skima (m)
|
Am very sure he must be coding with register_global=on. But this is not advisible. Enhanced code : works in any environment that supports php and support sendmail. <?PHP #Where you want the email to go $to = $_POST['useraddr'];
#subject of the message, change this $re = "Feedbackfromcontactpage"; /* *@header : this will show when the user click the reply button in the email client */ $header="From: Your own name<youremail@yoursite.com>\r\n"; $header.="Reply-to:<yourreplyemail@yourcompany.com>\r\n";
#message from the feedback form, don't touch this $msg = $_POST['comments'];
//CHECK TO MAKE SURE THE EMAIL IS VALID
if(!preg_match("/^[^\s()<>@,;:\"\/\[\]?=]+@\w[\w-]*(\.\w[\w-]*)*\.[a-z]{2,}$/i",$email)){ echo "Enter a valid email address";
}else{ //if the email was valid lets send it
#send the mail, don't edit this if(mail($to,$re,$msg,$header)){
echo " Your email has been sent! to $to."; }else{ echo "<p> Error sending mail!</p>"; }//end sending email
}//end validate email
?>
|
|
|
|
|
|
smartsoft (m)
|
i just knew that my register_global is kind of on, i better stop doing that hey bravo everybody who notice that
|
|
|
|
|
|