Domain Discussion Board

Go Back   Domain Discussion Board > Web Hosting & Web Design > Scripts

 
Reply
 
LinkBack Thread Tools Display Modes
[TUT] E-mail through PHP
Old
  (#1 (permalink))
Consumed
Member
Consumed is on a distinguished road
 
Consumed's Avatar
 
Status: Offline
Posts: 34
Points: 664.6
Bank: 2.9
Total Points: 667.5
Donate
Join Date: May 2006
Rep Power: 0
[TUT] E-mail through PHP - 05-17-2006, 07:56 PM

Well, this is made up of 2 codes. Here they are.
-----------------------------------------------------------------------------
<div>
<form name="contact" method="post" action="contactprocess.php">
<strong>Name:</strong><br/>
<input type="text" name="ename" size="30"><br/>
<strong>Email:</strong><br/>

<input type="text" name="eemail" size="30"><br/>
<strong>Subject:</strong><br/>
<input type="text" name="esubject" size="30"><br/>
<strong>Message:</strong><br/>

<textarea name="emessage" cols="30" rows="10"></textarea><br/>
<input type="submit" name="esubmit" value="Send Mail" style="cursorointer">
<input type="hidden" name="eip" value="<?php echo $_SERVER["REMOTE_ADDR"]; ?>">
</form>
</div>
-----------------------------------------------------------------------------
Save that as, contact.php
-----------------------------------------------------------------------------
<?php

//Some variables
$mymail = "myemail@address.com";
$ename = $_POST['ename'];
$eemail = $_POST['eemail'];
$esubject = $_POST['esubject'];
$emessage = $_POST['emessage'];
$eip = $_POST['eip'];

//Function to check email address
function checkemail($eemail) {
if(eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$eemail)) {
return true;
}
else {
return false;
}
}

//Mail Processing
if ($_POST['esubmit']) {
//Check for blank fields
if ($ename == "" || $eemail == "" || $esubject == "" || $emessage == "") {
echo "<p>It appears that you left a blank field.<br/> Please make sure you fill everything in.</p>";
}
//Check to see if the email address is valid
else if (checkemail($eemail) == false) {
echo "<p>It appears that you enter an invalid email address.<br/> Please check your email again.</p>";
}
//Send the email if there's no error
else {
$body = "$emessage\n\nName: $ename\nEmail: $eemail\nIp: $eip";
mail($mymail,$esubject,$body,"From: $eemail\n");
echo "<p>Thank you for your email $ename!</p>";
}
}

?>
-----------------------------------------------------------------------------
Put this in your Database
-Then upload the files and put the first code where you want it to be.
--I will be adding a demo soon
   
Reply With Quote
Re: [TUT] E-mail through PHP
Old
  (#2 (permalink))
jabapyth
Executive Member
jabapyth is an unknown quantity at this point
 
Status: Offline
Posts: 236
Points: 110.1
Bank: 1,834.2
Total Points: 1,944.3
Donate
Join Date: May 2006
Rep Power: 0
Re: [TUT] E-mail through PHP - 05-25-2006, 07:53 PM

too bad that only works if the host supports SMTP
   
Reply With Quote
Sponsored Links
Re: [TUT] E-mail through PHP
Old
  (#3 (permalink))
jabapyth
Executive Member
jabapyth is an unknown quantity at this point
 
Status: Offline
Posts: 236
Points: 110.1
Bank: 1,834.2
Total Points: 1,944.3
Donate
Join Date: May 2006
Rep Power: 0
Re: [TUT] E-mail through PHP - 05-26-2006, 12:27 PM

is there a way to use remote SMTP?
   
Reply With Quote
Re: [TUT] E-mail through PHP
Old
  (#4 (permalink))
IamShipon1988
Retired Moderator
IamShipon1988 is on a distinguished road
 
Status: Offline
Posts: 152
Points: 150.1
Bank: 1,005.7
Total Points: 1,155.9
Donate
Join Date: May 2006
Location: New York City
Rep Power: 3
Re: [TUT] E-mail through PHP - 05-29-2006, 10:06 AM

Quote:
<form name="contact" method="post" action="contactprocess.php">
Amm shouldn't that be
Quote:
<form name="contact" method="post" action="contact.php">
There is no file such as contactprcoess.php that you have asked to create
   
Reply With Quote
Re: [TUT] E-mail through PHP
Old
  (#5 (permalink))
Hydro
Member
Hydro is an unknown quantity at this point
 
Status: Offline
Posts: 64
Points: 256.2
Bank: 505.7
Total Points: 761.9
Donate
Join Date: May 2006
Location: Texas
Rep Power: 0
Re: [TUT] E-mail through PHP - 05-29-2006, 02:51 PM

Nice tutorial, I need this for my new site and Im a bit rusty on PHP so this will definitly help me
   
Reply With Quote
Re: [TUT] E-mail through PHP
Old
  (#6 (permalink))
Ottica
Executive Member
Ottica is on a distinguished road
 
Ottica's Avatar
 
Status: Offline
Posts: 321
Points: 66.6
Bank: 517.5
Total Points: 584.1
Donate
Join Date: May 2006
Location: Canada
Rep Power: 3
Re: [TUT] E-mail through PHP - 05-29-2006, 04:30 PM

Nice, that looks pretty simple. Looking over the code is definately a good way for people learning PHP (like me...) to improve/learn new skills.
   
Reply With Quote
Re: [TUT] E-mail through PHP
Old
  (#7 (permalink))
s-Lec
Platinum Member
s-Lec is an unknown quantity at this point
 
Status: Offline
Posts: 705
Points: 59.0
Bank: 1,806.1
Total Points: 1,865.1
Donate
Join Date: Jun 2006
Location: Auckland
Rep Power: 0
Re: [TUT] E-mail through PHP - 06-02-2006, 09:53 PM

Thank you so much! very helpful!


██ Love ME?
██ Visit My BLOG! Luv5! <3

   
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 0.1
Points Per Thread: 15.0
Points Per Reply: 5.0


Similar Threads
Thread Thread Starter Forum Replies Last Post
New yahoo mail sharkyinternet Chit-Chat Area - Internet Related 12 07-27-2007 05:57 AM
PHP script needed mtorregiani Scripts 19 06-30-2006 11:49 AM
any php coder here vignesh_natraj Member Help 8 05-22-2006 10:15 AM
PHP Help: Session IDs Momo Scripts 1 04-09-2006 06:28 PM


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 ©2007, Crawlability, Inc.