Go Back   Pictual Design Forums > Graphics > Tutorials
Top Posters Referers Register Members List Calendar Search Today's Posts Mark Forums Read

Tutorials Staged guides related to design, graphics and skinning.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-25-2005, 11:10 AM
FireNova FireNova is offline
Returning Member
Elite Member (500+ posts)
 
Location: Uk
Rep Power: 0
FireNova is an unknown quantity at this point
Send a message via MSN to FireNova
Default

Hey guys yes thats rite i learnt more php lol :P. today were learning the basic way to send emails from a form that can be place on sites. All of this is in one file.

First open a new document in any program notepad is easiest and name the file 'emailform.php' without the quotes.

Enter in this code
Code:
<?Php if( isset($_POST['submit']) ) { mail("email@url.com", "$subject" , "$email" , "$message"); echo '<b>Subject:</b> '.$subject.' <br /> <b>Email:</b> '.$email.' <br /> <b>Message:</b> <br /> '.$message.' <br /> <br /> <a href="emailform.php">Go Back</a>'; } else { echo ' <form method="post" action="emailform.php"> Subject: <input type="text" name="subject" size="15"><br /> Email: <input type="text" name="email" size="15"><br /> Message: <br /><textarea name="message" rows="10" cols="30"></textarea><br /> <input type="submit" name="submit" value="Send Email"> </form>'; }?>

now lets break it down

Code:
if( isset($_POST['submit']) ) { mail("email@url.com", "$subject" , "$email" , "$message"); echo '<b>Subject:</b> '.$subject.' <br /> <b>Email:</b> '.$email.' <br /> <b>Message:</b> <br /> '.$message.' <br /> <br /> <a href="emailform.php">Go Back</a>'; }
This says that if submit is clicked do whats in the { } brackets in this case this:
Code:
mail("email@url.com", "$subject" , "$email" , "$message"); echo '<b>Subject:</b> '.$subject.' <br /> <b>Email:</b> '.$email.' <br /> <b>Message:</b> <br /> '.$message.' <br /> <br /> <a href="emailform.php">Go Back</a>';
now lets break it down even further
Code:
mail("email@url.com", "$subject" , "$email" , "$message");
This says when submit is clicked mail the info to 'email@url.com'.

It also says that the info sent is the varibles subject, email and message.
Code:
echo '<b>Subject:</b> '.$subject.' <br /> <b>Email:</b> '.$email.' <br /> <b>Message:</b> <br /> '.$message.' <br /> <br /> <a href="emailform.php">Go Back</a>';
this says after the info is sent echo the info in the speechmarks in this case it tells it to produce text like this

subject: blah
email: blah
message: blah

Go Back

after the subject, email and message the varibles can be seen in the coding. This basically means that it will echo what you just sent. So if you wrote this in the name part "My name is Tom" then it will do this

subject: My name is Tom
Code:
else { echo ' <form method="post" action="emailform.php"> Subject: <input type="text" name="subject" size="15"><br /> Email: <input type="text" name="email" size="15"><br /> Message: <br /><textarea name="message" rows="10" cols="30"></textarea><br /> <input type="submit" name="submit" value="Send Email"> </form>';
The 'else' tells the php that if the submit is not clicked then go to this. As like before the echo can be seen. This says if else is use then echo this form onto the page.
The form is easy and if you have basic knowledge of html then you know what this is.

An example of this can be seen at

http://p3rc3pt10n.net/site/tuts/php/emailform.php

if you need help feel free to ask all comments are appreciated :P

<span style='color:red'>
*Note: To all those expert programmers if i have anything wrong please tell me as im not experience in php and correcting it will help get me and other members better.</span>
Reply With Quote
  #2  
Old 06-25-2005, 11:47 AM
Insaze Insaze is offline
Returning Member
Advanced Member (50+ posts)
 
Rep Power: 0
Insaze is off the scale
Default

haha that script is nasty
i remember the times when i did nasty, and i really mean nasty things with it ^^

oh yeah btw good tut..
Reply With Quote
  #3  
Old 06-25-2005, 01:44 PM
ownsyou ownsyou is offline
Returning Member
Advanced Member (50+ posts)
 
Location: England
Rep Power: 0
ownsyou is an unknown quantity at this point
Send a message via MSN to ownsyou
Default

Code:
if($submit) { mail("email@url.com", "$subject" , "$email" , "$message"); echo '<b>Subject:</b> '.$subject.' <br /> <b>Email:</b> '.$email.' <br /> <b>Message:</b> <br /> '.$message.' <br /> <br /> <a href="emailform.php">Go Back</a>'; }

It would only work if "register_globals" are ON in php.ini, if it is ON, there is a security risk, change it to:

Code:
if( isset($_POST['submit']) ) { mail("email@url.com", "$subject" , "$email" , "$message"); echo '<b>Subject:</b> '.$subject.' <br /> <b>Email:</b> '.$email.' <br /> <b>Message:</b> <br /> '.$message.' <br /> <br /> <a href="emailform.php">Go Back</a>'; }

Hope it helps!
Reply With Quote
  #4  
Old 06-25-2005, 01:46 PM
FireNova FireNova is offline
Returning Member
Elite Member (500+ posts)
 
Location: Uk
Rep Power: 0
FireNova is an unknown quantity at this point
Send a message via MSN to FireNova
Default

thanks for this James
Reply With Quote
  #5  
Old 07-01-2005, 07:56 PM
xplicit xplicit is offline
Deathgod - Shinigami
Lives Here
Elite Member (500+ posts)
 
Location: U.S.
Rep Power: 0
xplicit is an unknown quantity at this point
Default

Only If i knew how to do php, looks like a headache waiting to happen. T_T
__________________
www.BrianLeee.com - Online Portfolio
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Arrays ownsyou Tutorials 4 03-05-2006 11:03 AM
Simple Content Box and Slicing FireNova Tutorials 5 02-04-2006 01:05 AM
Protect your e-mail account Glitch Computers & Games 2 12-02-2005 04:46 AM
Introduction to Php dbfootballa3 Tutorials 11 12-01-2005 11:33 AM
Php Randomizing images FireNova Tutorials 3 06-19-2005 04:00 PM


All times are GMT -4. The time now is 01:37 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.