Go Back   Webmaster Forum > Development > Programming > PHP
REMOVE the ads below !
Reply
 
LinkBack Thread Tools
  # 1 (permalink)
Old
Junior Geek
Posts: 142
Join Date: Feb 2007
iTrader: (0)
Post PHP 03/04 : Example - 09-27-2007

As before an example with some addons, read it carefully

PHP Code:
<?php if(!empty($_POST['text']) && !empty($_POST['mail']))

/* empty() is a function to check if a variable is empty or not
the "!" means "not"
&& is used in "if" and "while" to add some condition, it means "AND"
 and could be replaced by "or" or "||" (the same thing)*/

{
$to 'myname@example.com';
$subject 'Mail from my website';
$message $_POST['text']; // you could use directly $_POST['text']
$headers 'From: '.$_POST['mail']."\r\n" .
     
'Reply-To: '.$_POST['mail']."\r\n" .
     
'X-Mailer: PHP/' phpversion();

     
mail($to$subject$message$headers);
}
?>
<form method="post">Mail : <input type="text" name="mail">
<br>You're text<texterea name="text"></texterea>
<br><input type="submit" value="send"></form>
As before I put 5 errors on the next code, who's the same as the up. try to find them and search the reason why :

PHP Code:
<?php if(!empty($_POST['text']) & empty($_POST['mail'])

/* empty() is a function to check if a variable is empty or not
the "!" means "not"
&& is used in "if" and "while" to add some condition, it means "AND"
 and could be replaced by "or" or "||" (the same thing)*/

{
$to 'myname@example.com';
$subject 'Mail from my website';
$message $_POST['text']; // you could use directly $_POST['text']
$headers 'From: '.$_POST['mail'] .
     
'Reply-To: '.$_POST['mail']."\r\n" .
     
'X-Mailer: PHP/' phpversion();

     
mail($to$subject$message$headers)
}
?>
<form method="post">Mail : <input type="text" name="mail">
<br>You're text<texterea name="text"></texterea>
<br><input type="submit" value="send"></form>


Thanks,
Aqua


-------------------
http://www.aquafolie.org

Last edited by aquafolie : 09-27-2007 at 04:40 PM.
Reply With Quote
Reply


Thread Tools



PSD to HTML

vBulletin®, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd. | SEO by vBSEO | Skin developed by vBStyles.com