I am trying to create a php file that sends some information to the recipient's email address . My code works but , it only sends the $data and not the $key as well .
I want this php script to make the following output :
Firstname : Theodore (for example)
Lastname : Zerbas (for examle)
Is there somebody to help me out ? thank you for your time.
I want this php script to make the following output :
Firstname : Theodore (for example)
Lastname : Zerbas (for examle)
Is there somebody to help me out ? thank you for your time.
Code:
$firstname = $_POST['fname']; $lastname = $_POST['lname']; $to = "example@example.com"; $message = array("name"=>$firstname,"lastname:"=>$lastname); foreach($message as $key=>$data) { $message[]=implode("<br/>",$key.':'.$data); } if(mail($to,$subject,implode("<br/>",$message),implode("\r\n",$headers))) { echo "Your message has been sent successfully"; } else {echo " Something went wrong";}
Comment