Brett Posted January 4, 2021 Share Posted January 4, 2021 I can get "Name" etc to show on the email but not the value. eg: Name: What I need is Name: Joe Smith Here is the code: <?php if($_POST["submit"]) { $recipient="my@email.address"; $subject="Form to email message"; $sender=$cemail; $mailBody="Customers Business Name: $cbname\n $cname=Customers Name: $cname\n $caddress=Customers Address: $caddress\n $csuburb=Customers Suburb: $csuburb\n $ccity=Customers City: $ccity\n $cphone=Customers Phone Number: $cphone\n $cemail=Customers Email: $cemail\n\n $sbname=Senders Business Name: $sbname\n $sname=Senders Name: $sname\n $saddress=Senders Address: $saddress\n $ssuburb=Senders Suburb: $ssuburb\n $scity=Senders City: $scity\n $sphone=Senders Phone Number: $sphone\n\n $rbname=Receivers Business Name: $rbname\n $rname=Receivers Name: $rname\n $raddress=Receivers Address: $raddress\n $rsuburb=Receivers Suburb: $rsuburb\n $rcity=Receivers City: $rcity\n $rphone=Receivers Phone Number: $rphone\n\n $item=Item: $item\n $length=Length: $length\n $width=Width: $width\n $height=height: \n\n $message=Additional Information: "$message; mail($recipient, $subject, $mailBody, "From: $sender <$cemail>"); header('Location: thanks.php'); } ?> Here is the form <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Contact form to email</title> </head> <body> <form method="post" action="action.php"> <label>Customers Business Name:</label> <input name="cbname"><br> <label>Customers Name:</label> <input name="cname"><br> <label>Cusotmers Address:</label> <input name="caddress"><br> <label>Customers Suburb:</label> <input name="csuburb"><br> <label>Customers City:</label> <input name="ccity"><br> <label>Customers Phone Number:</label> <input name="cphone"><br> <label>Customers Email:</label> <input name="cemail"><br> <label>Senders Business Name:</label> <input name="sbname"><br> <label>Senders Name:</label> <input name="sname"><br> <label>Senders Address:</label> <input name="saddress"><br> <label>Senders Suburb:</label> <input name="ssuburb"><br> <label>Senders City:</label> <input name="scity"><br> <label>Senders Phone Number:</label> <input name="sphone"><br> <label>Receivers Business Name:</label> <input name="rbname"><br> <label>Receivers Name:</label> <input name="rname"><br> <label>Receivers Address:</label> <input name="raddress"><br> <label>Receivers Suburb:</label> <input name="rsuburb"><br> <label>Receivers City:</label> <input name="rcity"><br> <label>Receivers Phone Number:</label> <input name="rphone"><br> <label>Item:</label> <input name="item"><br> <label>Length in cm:</label> <input name="length"><br> <label>Width in cm:</label> <input name="width"><br> <label>Height in cm:</label> <input name="hight"><br> <label>Weight in kg:</label> <input name="weight"><br> <label>Additional Information:</label> <textarea rows="5" cols="20" name="info"></textarea> <input type="submit" name="submit"> </form> </body> </html> Thanks for any help for can give. Quote Link to comment https://forums.phpfreaks.com/topic/311973-form-to-email/ Share on other sites More sharing options...
benanamen Posted January 4, 2021 Share Posted January 4, 2021 The form data is in the POST array which you do nothing with. Besides that, this code will be vulnerable to an Email Header Injection Attack if it were to work. Quote Link to comment https://forums.phpfreaks.com/topic/311973-form-to-email/#findComment-1583650 Share on other sites More sharing options...
Brett Posted January 4, 2021 Author Share Posted January 4, 2021 Thank you, how do I fix it? Quote Link to comment https://forums.phpfreaks.com/topic/311973-form-to-email/#findComment-1583654 Share on other sites More sharing options...
maxxd Posted January 4, 2021 Share Posted January 4, 2021 By using the $_POST array like you do in the opening conditional. None of the variables you're using in the body string are defined when you try to use them. Quote Link to comment https://forums.phpfreaks.com/topic/311973-form-to-email/#findComment-1583659 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.