Chronix Posted November 25, 2010 Share Posted November 25, 2010 Hi all, first time posting here and wondering if anyone can help me. Ive linked a button in a HTML so that it sends an email to me. But the thing thats really bugging me is that sometimes it sends the persons email address and sometimes it doesnt AND ALSO ive got multiple boxes in my HTML that I want it to send but it will only send 1 and not all 5. This is what my PHP looks like at the moment: <?php $email = $_REQUEST[ 'email_box' ] ; $message = $_REQUEST[ 'test1_box' ] ; $message = $_REQUEST[ 'test2_box' ] ; $message = $_REQUEST[ 'test3_box' ] ; $message = $_REQUEST[ 'test4_box' ] ; $message = $_REQUEST[ 'test5_box' ] ; mail( "[email protected]", "Test Feedback sheet", $message, "From: $email" ); ?> Can you please tell me where I have gone wrong? I really need this to be sorted out and im completely new to PHP, ive only just gotten past basic knowledge of html Link to comment https://forums.phpfreaks.com/topic/219832-php-linked-to-button/ Share on other sites More sharing options...
litebearer Posted November 25, 2010 Share Posted November 25, 2010 1. ALWAYS test/check/cleanse variables BEFORE using them 2. Use $_POST or $ _Get to gather your variables rather than $_REQUEST 3. The way you have it set up , $message will only have test5_box, you need to concantate them Link to comment https://forums.phpfreaks.com/topic/219832-php-linked-to-button/#findComment-1139583 Share on other sites More sharing options...
Chronix Posted November 25, 2010 Author Share Posted November 25, 2010 3. The way you have it set up , $message will only have test5_box, you need to concantate them How do I do that? Link to comment https://forums.phpfreaks.com/topic/219832-php-linked-to-button/#findComment-1139586 Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2010 Share Posted November 25, 2010 With the concatenation operator $var1 = 'string1'; $var1 .= ' string2'; $var1 now contains 'string1 string2' . . . Link to comment https://forums.phpfreaks.com/topic/219832-php-linked-to-button/#findComment-1139697 Share on other sites More sharing options...
Chronix Posted November 26, 2010 Author Share Posted November 26, 2010 Thanks for the help, I got the email to work properly now but im having problems with the php page loading a HTML after it has submitted the email. Heres the code im using: <?php $email = $_POST[ 'email_box' ] ; $message1 = $_POST[ 'test1_box' ] ; $message2 = $_POST[ 'test2_project_box' ] ; $message3 = $_POST[ 'test3_box' ] ; $message4 = $_POST[ 'test4_box' ] ; $message5 = $_POST[ 'test5_box' ] ; mail("[email protected]", 'Test Email Feedback Form', "test email: ".$email."\n\ntest1: ".$message1."\n\ntest2: ".$message2."\n\ntest3:".$message3."\n\ntest4: ".$message4."\n\ntest5: ".$message5, "From: $email"); header( 'Location:thankyou.html' ) ; ?> Whats gone wrong? It keeps saying Warning: Cannot modify header information - headers already sent by everytime sendmail.php loads Link to comment https://forums.phpfreaks.com/topic/219832-php-linked-to-button/#findComment-1139877 Share on other sites More sharing options...
Pikachu2000 Posted November 26, 2010 Share Posted November 26, 2010 You can't send headers after they've already been sent. I.e. you can't use a header() redirect if there has already been any output at all to the browser, even as little as a single space or character. Link to comment https://forums.phpfreaks.com/topic/219832-php-linked-to-button/#findComment-1139969 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.