HTML to PHP variable not working correctly

Hello everyone,

I’m working on a membership application for my amateur radio club. The problem I am having is the section where the applicant is being asked if he wants to purchase a name tag. The issue I am getting now is no matter what name tage type. I’m still getting the same variable.

Below is the HTML code:

<tr>
    <td width="5%">&nbsp;</td>
    <td class="bosytext" width="15%">Name tag clip type</td>
    <td class="bosytext" width="75%"><input type="radio" name="nametag" value="10" size="2" id="nametag"> Standard Clip ($10)<input type="radio" name="nametag" value="15" size="2"> Magnet Clip ($15) <input type="radio" name="nametag" value="0" checked size="1"> No Name Tag
    <td width="5%">&nbsp;</td>
</tr>

Below is the PHP code:

<?php
	$to = '[email protected]';
	$subject = 'SFARC Member application Test';
	$from = '[email protected]';
 
// To send HTML mail, the Content-type header must be set
	$headers  = 'MIME-Version: 1.0' . "\r<br>";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r<br>";
 
// Create email headers
	 $headers .= 'From: '.$from."\r<br>".
         'Reply-To: '.$from."\r<br>" .
         'X-Mailer: PHP/' . phpversion();

// Declare PHP variables from html input
 
 	 $App_Date = date('F jS, Y');
         $First_Name = $_POST['firstname'];
         $Last_Name = $_POST['lastname'];
         $Nick_Name = $_POST['nickname'];
         $Address = $_POST['homeaddress'];
         $City_town = $_POST['citytown'];
         $Zip_code = $_POST['zipcode'];
         $Email = $_POST['emailaddress'];
         $Home_phone = $_POST['homephone'];
         $Cell_phone = $_POST['cellphone'];
         $Call_sign = $_POST['callsign'];
         $Arrl_member = $_POST['arrlmember'];
         $Membership_type = $_POST['membershiptype'];
         $Membership_term = $_POST['membershipterm'];
         $Donation_Amount = $_POST['donation'];
         $Name_Tag = $_POST['nametag'];
         $Repeater_Fund = $_POST['repeaterfund'];

 // Calculate membership fee
         if($Membership_term >= 2){		
            $Fee = 20;
         }else {
            $Fee = 22;
         }
    
 // Calculate dues
 	 $Membership_dues = ($Fee * $Membership_term);
 	 
 // Name tag type
 	 if($Name_Tag = 15) {	
		$Tag_Type="Magnetic";
	 }elseif($Name_Tag = 10) {	
	 	$Tag_Type="Standard";
	 }	else {
		$Tag_Type="No Name Tag";
	 }	
	 
 // Calculate grandtotal
 	 $Total_Fee = ($Membership_dues + $Name_Tag) + ($Donation_Amount + $Repeater_Fund);    	
    	
 // Application sent emailed to SFARC
	 $message = 'Date: '.$App_Date."\n".'First Name: '.$First_Name."\n".'Last Name: '.$Last_Name."\n".'Nick Name: '.$Nick_Name."\n".'Address: '.$Address."\n".'City/Town: '.$City_town."\n".'Zip Code: '.$Zip_code."\n".'Email: '.$Email."\n".'Home Phone: '.$Home_phone."\n".'Cell Phone: '.$Cell_phone."\n".'Callsign: '.$Call_sign."\n".'ARRL Member: '.$Arrl_member."\n".'Membership Type: '.$Membership_type."\n".'Membership Term: '.$Membership_term." year(s)"."\n".'Name Tag Type: '.$Tag_Type.' $'.$Name_Tag."\n".'Membership Dues: $'.$Membership_dues."\n".'Donation Amount: $'.$Donation_Amount."\n".'Repeater Fund: $'.$Repeater_Fund."\n".'Total Amount Due: $'.$Total_Fee."\n";
 
// Displays application in a webpage for applicant
if(mail($to, $subject, $message, $headers )){
	echo '<p align="center">Your application has been submitted successfully. Please pay $'.$Total_Fee.' at the next meeting, or you can pay via PayPal.';
	echo '<table>';
	echo 		'<tr>';
	echo			'<td align="center"><font color="#000000"><form action="https://www.paypal.com/cgi-bin/webscr" method="post">';
	echo				'<div align="center">';
	echo					'<input type="hidden" name="cmd" value="_s-xclick">';
	echo					'<input type="hidden" name="hosted_button_id" value="RT3WUGBNPS9CG">';
  	echo					'<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" />';
  	echo					'![|1x1](upload://co84kRo5eefwC6rrqw6AdrITTvv.gif)</div>';
   echo			'</td>';
	echo		'</tr>';
	echo '</table>';
	echo '</p>';
} else{
	echo 'Unable to submit your membership application. Please try again.';
};
?>

* Admin Edit: Added Code Format tags.

Please reformat your code so we can read it and copy it to our editors.
To do this use either the QUOTE or Pre-Formatted tags.
Re-post the code section and TAG it with the appropiate tags and then we can read it and help you.

$message = "
Date: $App_Date\n
First Name: $First_Name\n
Last Name: $Last_Name\n
Nick Name: $Nick_Name\n
Address: $Address\n
City/Town: $City_town\n
Zip Code: $Zip_code\n
Email: $Email\n
Home Phone: $Home_phone\n
Cell Phone: $Cell_phone\n
Callsign: $Call_sign\n
ARRL Member: $Arrl_member\n
Membership Type: $Membership_type\n
Membership Term: $Membership_term year(s)\n
Name Tag Type: $Tag_Type \$$Name_Tag\n
Membership Dues: \$$Membership_dues\n
Donation Amount: \$$Donation_Amount\n
Repeater Fund: \$$Repeater_Fund\n
Total Amount Due: \$$Total_Fee\n";

Does this all look correct?

Yes looks correct. What does “$” do?

When multiple inputs have the same name add array notation to their name

<input name="type[]"> then your $_POST data will contain a type whose value is an array of all selected values.

I don’t understand the question.

$name is a variable. Outside of that I don’t know what you are referring too.

Sponsor our Newsletter | Privacy Policy | Terms of Service