How to send msg from ur web site.

Write your "How To" regarding anything you are comfortable with and you feel it will help the forum members.

NOTE :: All threads started here will appear only after the approval from Administrator
Post Reply
Gyanu
Posts: 338
Joined: Mon Jul 30, 2007 2:03 pm
Contact:

How to send msg from ur web site.

Post by Gyanu »

I always use to use these codes in my site to send msgs.

In the step creat a page named contact.html and insert the following codes.

[HTML]<form method="POST" action="contact.php">
Fields marked (*) are required

<p>Name:

<input type="text" name="Name">
<p>Address:

<input type="text" name="Address">
<p>Phone:

<input type="text" name="Phone">
<p>Website:

<input type="text" name="Website">
<p>Comments:

<textarea name="Comments"></textarea>
<p><input type="submit" name="submit" value="Submit">
</form>[/HTML]

And after that creat another page called contact.php and paste following codes.

[PHP]<?php
$EmailFrom = "Server";
$EmailTo = "u@u.com";
$Subject = "Msg from server.....";
$Name = Trim(stripslashes($_POST['Name']));
$Address = Trim(stripslashes($_POST['Address']));
$Phone = Trim(stripslashes($_POST['Phone']));
$Website = Trim(stripslashes($_POST['Website']));
$Comments = Trim(stripslashes($_POST['Comments']));

$validationOK=true;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
exit;
}

$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Address: ";
$Body .= $Address;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Phone;
$Body .= "\n";
$Body .= "Website: ";
$Body .= $Website;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $Comments;
$Body .= "\n";

$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=ok.htm\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
[/PHP]

And now in next step creat to pages called ok.hrml (type in this page that "Message was sucessfully send") and errot.html (type in this page that "Error occured while sending message")

Now opload it in ur site and test it.
you can use it in any way.


Image
SHAdmin
Posts: 2089
Joined: Sat Dec 18, 2004 11:28 am
Contact:

Post by SHAdmin »

Your 'How To' has been approved and 10 points have been credited into your account for sharing it.
Post Reply