I'm very new to PHP and I want to create a customer feedback form on a website.
Here and the relevant links:
http://www.macquariemint.com/sendmail.php
http://www.macquariemint.com/customerfeedback.html
http://www.macquariemint.com/thankyou.html
So far I've only implemented the following sections:
First Name
Last Name
E-mail Address
Street Address
City/Suburb
State
Postcode
Australian Decimal Coins and/or Banknotes check box.
What I want to happen is; a user inputs the data, its get emailed to my account and they are redirected to the thank you page.
The problem I'm having is with the check box. It works fine when the box is selected - but when its not selected I get the following error:
Notice: Undefined index: decimal in D:\Inetpub\Macquariemint\sendmail.php on line 10
Warning: Cannot modify header information - headers already sent by (output started at D:\Inetpub\Macquariemint\sendmail.php:10) in D:\Inetpub\Macquariemint\sendmail.php on line 15
I need the data to be emailed to me and the user redirected regardless if any of the check boxes are selected or not.
Can anyone give me a hand with the check box problem I am having, it would be greatly appreciated.
PHP form checkbox problem.
Moderator: General Moderators
-
JohnJJones
- Forum Newbie
- Posts: 4
- Joined: Tue Nov 28, 2006 9:48 pm
Code: Select all
<?
$firstname = $_REQUEST['firstname'];
$lastname = $_REQUEST['lastname'];
$emailaddress = $_REQUEST['emailaddress'];
$streetaddress = $_REQUEST['streetaddress'];
$citysuburb = $_REQUEST['citysuburb'];
$state = $_REQUEST['state'];
$postcode = $_REQUEST['postcode'];
$collectcomments = $_REQUEST['collectcomments'];
$suggestion = $_REQUEST['suggestion'];
$comments = $_REQUEST['comments'];
mail( "jjones@downies.com", "Feedback Form Results",
"First Name: $firstname\nLast Name: $lastname\nEmail address: $emailaddress\nStreet Address: $streetaddress\nCity/Suburb: $citysuburb\nState: $state\nPostcode: $postcode\nOther Collecting Comments: $collectcomments\nFuture Offers: $suggestion\nOther Comments: $comments", "From: $emailaddress" );
header( "Location: http://www.macquariemint.com/thankyou.html" );
?>
An unselected checkbox is not sent at all as http parameter, check the existance via isset.
The word decimal does not appear in the code snippet you've posted here.JohnJJones wrote:Notice: Undefined index: decimal in D:\Inetpub\Macquariemint\sendmail.php on line 10
-
JohnJJones
- Forum Newbie
- Posts: 4
- Joined: Tue Nov 28, 2006 9:48 pm
should be something like
Code: Select all
if ( isset($_REQUEST['decimal']) ) {
$decimal = 'decimal set';
}
else {
$decimal = 'decimal not set';
}
// or shorter
$decimal = isset($_REQUEST['decimal']) ? 'decimal set' : 'decimal not set';-
JohnJJones
- Forum Newbie
- Posts: 4
- Joined: Tue Nov 28, 2006 9:48 pm
Code: Select all
$decimal = isset($_REQUEST['decimal']) ? 'Yes' : 'No';
I may need some assistance with 'radio' elements next... But I'll try a few things before I bug you guys again.
Thank you again, its just what I was after!