Help with php form upload script

Discussion in 'PHP' started by Barq, Mar 14, 2011.

  1. #1
    Hi I have my php form upload script and now I am trying to add radio buttons to my website and the upload script but I don't understand how to add the radio buttons so it just returns the selected option in the email, the way I have it it is returning all options and answers checked or uncheckd on the radio buttons

    Thanks for any help

    
    $radiobutton2_is_required = 0;
    $radiobutton2_is_required = 0;
    $checkbox_is_required = 0;
    $checkbox2_is_required = 0;
    $checkbox3_is_required = 0;
    $checkbox4_is_required = 0;
    $email_is_required = 1;
    $name_is_required = 1;
    $phone_is_required = 0;
    $comments_is_required = 0;
    $uself = 0;
    $use_envsender = 0;
    $use_sendmailfrom = 0;
    $smtp_server_win = '' ;
    $use_webmaster_email_for_from = 0;
    $use_utf8 = 1;
    $my_recaptcha_private_key = '' ;
    
    // -------------------- END OF CONFIGURABLE SECTION ---------------
    
    define( 'MAX_LINE_LENGTH', 998 );
    $headersep = (!isset( $uself ) || !$uself) ? "\r\n" : "\n" ;
    $content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ;
    if (!isset( $use_envsender )) { $use_envsender = 0 ; }
    if (isset( $use_sendmailfrom ) && $use_sendmailfrom) {
    	ini_set( 'sendmail_from', $mailto );
    }
    if (isset( $smtp_server_win ) && strlen($smtp_server_win)) {
    	ini_set( 'SMTP', $smtp_server_win );
    }
    $envsender = "-f$mailto" ;
    $fullname = (isset($_POST['fullname']))? $_POST['fullname'] : $_POST['name'] ;
    $email = $_POST['email'] ;
    $phone = $_POST['phone'] ;
    $RESP = $_POST['RESP'] ;
    $withbank = $_POST['withbank'] ;
    $comments = $_POST['comments'] ;
    $http_referrer = getenv( "HTTP_REFERER" );
    
    if (!isset($_POST['email'])) {
    	header( "Location: $formurl" );
    	exit ;
    }
    if (($email_is_required && (empty($email) || !preg_match('/@/', $email))) || ($name_is_required && empty($fullname)) || ($comments_is_required && empty($comments))) {
    	header( "Location: $errorurl" );
    	exit ;
    }
    if ( preg_match( "/[\r\n]/", $fullname ) || preg_match( "/[\r\n]/", $email ) ) {
    	header( "Location: $errorurl" );
    	exit ;
    }
    if (strlen( $my_recaptcha_private_key )) {
    	require_once( 'recaptchalib.php' );
    	$resp = recaptcha_check_answer ( $my_recaptcha_private_key, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] );
    	if (!$resp->is_valid) {
    		header( "Location: $errorurl" );
    		exit ;
    	}
    }
    if (empty($email)) {
    	$email = $mailto ;
    }
    $fromemail = (!isset( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0)) ? $email : $mailto ;
    
    if (function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc()) {
    	$comments = stripslashes( $comments );
    }
    
    $messageproper =
    	"This message was sent from:\n" .
    	"$http_referrer\n" .
    	"------------------------------------------------------------\n" .
    	"------------------------- Max Grant -------------------------\n\n" .
    	"400: $checkbox\n" .
    	"500: $checkbox2\n" .
    	"800: $checkbox3\n" .
    	"1000: $checkbox4\n" .
    	"------------------------- Who can contribute -------------------------\n\n" .
    [COLOR="red"]	"Parents Only: $radiobutton2\n" .
    	"Parents and Grand: $radiobutton2\n" .[/COLOR]
    	"------------------------------------------------------------\n" .
    	"Name of sender: $fullname\n" .
    	"Email of sender: $email\n" .
    	"Phone of sender: $phone\n" .
    	"Do you currently have a bank: $RESP\n" .
    	"If so, is it with a bank?: $withbank\n" .
    	"------------------------- COMMENTS -------------------------\n\n" .
    	wordwrap( $comments, MAX_LINE_LENGTH, "\n", true ) .
    	"\n\n------------------------------------------------------------\n" ;
    
    $headers =
    	"From: \"$fullname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.16.1" .
    	$headersep . 'MIME-Version: 1.0' . $headersep . $content_type ;
    
    if ($use_envsender) {
    	mail($mailto, $subject, $messageproper, $headers, $envsender );
    }
    else {
    	mail($mailto, $subject, $messageproper, $headers );
    }
    header( "Location: $thankyouurl" );
    exit ;
    
    ?>
    
    Code (markup):
     
    Barq, Mar 14, 2011 IP