Hey, Can someone see if they can work out why this code appears not to be working correctly? <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> <p>Your Name:<br> <input name="name" type="text" /> </p> <p>Your Email:<br> <input name="email" type="text" /> </p> <p>Subject:<br> <input name="subject" type="text" /> </p> <p>Message:<br> <textarea name="message" rows="6"></textarea> <br /> <input type="submit" value="Send" /><input type="hidden" name="do" value="send" /><input type="reset" value="Reset" /> </p></form> <?php if($_POST['do']=="send") { $recipient="myemail@hotmail.com"; // Set your email here // $subject=$_POST['subject']; $name=$_POST['name']; $email=$_POST['email']; $message=$_POST['message']; $formsend=mail("$recipient", "$subject", "$message", "From: $name ($email)\r\nReply-to:$email"); echo("<p>Your message was successfully sent!</p>"); } ?> Code (markup):
what is your problem ? mail send or not ? test it : $formsend=mail($recipient, $subject, $message, "From: $name ($email)\r\nReply-to:$email");
What exactly isn't working? If the problem lies in the form post, maybe try this: <form method="post" action="<?=$_SERVER['PHP_SELF']; ?>">
but if the action is empty or feel wirh PHP_SELF . that code should work ! beacuse all codes writed on 1 page ! and empty action is == $-SERVER['PHP_SELF']
GolfHos was right (and posted the solution); you aren't echoing out the "action" value in php. Change this: <form method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> Code (markup): To this: <form method="post" action="<?php [b]echo[/b] $_SERVER['PHP_SELF']; ?>"> Code (markup):
You need to validate your incoming data. If i were to set Name to: Bob\r\nCc:user1@domain.com,user2@domain.com THe email would be sent out to those other addresses too...