PHP Mailform dosen't work anymore

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Slightly off-topic and horsing back to the initial post but

Code: Select all

$z++;$b[$z]="realname  :".$realname."\n";
Could be written as:

Code: Select all

$b[++$z]="realname  :".$realname."\n";
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Re: PHP Mailform dosen't work anymore

Post by aerodromoi »

oliver23 wrote: Perfekt! :D

One more question, is it possible to forward it to another site (danke.html) if the sending was okay? A redirect instead of

Code: Select all

print ("Thanks!")

Code: Select all

<?php
// fetch the variables from the post array
$firma       = $_POST['firma'];
$realname    = $_POST['realname'];
$senderemail = $_POST['senderemail'];

$recipient = "name@domain.ch";
$subject   = "Kontaktformular";
$letter    = "Email: " . $senderemail . "\n";
$letter   .= "Firma: " . $firma . "\n";
$letter   .= "Name: " . $realname;

if (ereg('(cc\:|bcc\:|to\:)', strtolower($senderemail))){
  $header    = "X-Mailer: PHP " . phpversion();
}
else{
  $header    = "From: " . $senderemail;
} 

// check whether all fields have been filled in
if (empty($firma) || empty($realname) || empty($senderemail)){
  print("Sorry, all fields are required!");
}
else{       
  $result = @mail($recipient,$subject,$letter,$header); 
  $result ? header("Location: http://www.anonexistantdomain.com/") : print ("An error occurred!");
}
?>
btw: Any output before the header function will produce errors.
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Post by aerodromoi »

d11wtq wrote:Slightly off-topic and horsing back to the initial post but

Code: Select all

$z++;$b[$z]="realname  :".$realname."\n";
Could be written as:

Code: Select all

$b[++$z]="realname  :".$realname."\n";
You must be flabbergasted that there are still people out there who use the mail() function ;)
Post Reply