triplea Posted August 23, 2007 Share Posted August 23, 2007 Can someone help me pls. I will show code below. I'm using a contact form and trying to add input=radio and input=checkbox. I not a PHP expert and do not know if I'm adding the string correctly. See bottom of code. I also hv a check box for a "an agreement disclaimer" and need this to be mandatory when submitting form. Pls see below and if someone can help please. <span class="htext">Donate to the Poverello Thrift Stores</span> <?php /********************************************************* This Free Script was downloaded at Free-php-Scripts.net (HelpPHP.net) This script is produced under the LGPL license Which is included with your download. Not like you are going to read it, but it mostly States that you are free to do whatever you want With this script! NOTE: Linkback is not required, but its more of a show of appreciation to us. *********************************************************/ //Include configuration file and function file //(default location is in the same directory) include_once('config.php'); include_once('functions.php'); //If contact is being sent: if($_POST['submit_id'] == 1){ //Check fname entered if($_POST['fname'] == NULL){ $message = 'Please enter your first name.';} //Check lname entered if($_POST['lname'] == NULL && $message == NULL){ $message = 'Please enter your last name.';} //Check business name entered //if($_POST['busname'] == NULL && $message == NULL){ $message = 'Please enter your business or organization name.';} //Check address1 entered if($_POST['address1'] == NULL && $message == NULL){ $message = 'Please enter a address.';} //Check address2 entered //if($_POST['address2'] == NULL && $message == NULL){ $message = 'Please enter a address.';} //Check City entered if($_POST['city'] == NULL && $message == NULL){ $message = 'Please enter your city.';} //Check zip code entered if($_POST['zip'] == NULL && $message == NULL){ $message = 'Please enter your zip code.';} //Check home phone entered if($_POST['hphone'] == NULL && $message == NULL){ $message = 'Please enter your home phone.';} //check if email is enetered if($message == NULL && is_valid_email($_POST['email']) == false ){ $message = 'Please enter a valid email.';} //Check User web name entered //if($_POST['webname'] == NULL && $message == NULL){ $message = 'Please enter your web name.';} //Check target amount entered //if($_POST['target'] == NULL && $message == NULL){ $message = 'Please enter your Fundraising target amount.';} //check if message is entered if($_POST['message_text'] == NULL && $message == NULL){ $message = 'Please enter List/description of ietms to pick up.';} //check if message is entered //if($_POST['agreem'] == NULL && $message == NULL){ $message = 'Please check off you have read and agree to the Disclaimer terms.';} //check if image entered //if($_FILES['user_file'][name] == NULL && $message == NULL){ $message = 'Please enter a file to upload.';} //File Upload checks if($message == NULL && $FILE_UPLOAD == 1 && $_FILES['user_file']['name'] != NULL){ if($_FILES['user_file']['size'] > (($FILE_UPLOAD_MAX*1024)*1024)){ $message = 'File is over '.$FILE_UPLOAD_MAX.' MB in size.';} if($message == NULL && allowed_ext($FILE_UPLOADS_EXT,$_FILES['user_file']['name']) == false){$message = 'Invalid extension.';} $new_filename = date("G_i_s_").$_FILES['user_file']['name'];} //Image verificaiton checks if($message == NULL && $IMAGE_VERIFICATION == 1){ $te_co = hex2bin($_POST['hid_code']); $word_is = RC4($te_co,$IMAGE_VER_CODE); if($word_is != $_POST['confirm_image']){$message = 'Your verfication code is incorrect.';} } //End verifications, start processing if($message == NULL){ //Check if file upload is needed if($FILE_UPLOAD == 1 && $_FILES['user_file']['name'] != NULL){ //Store file for keep and email move_uploaded_file($_FILES['user_file']['tmp_name'],$FILE_UPLOADS_DIR.$new_filename); } //compose admin/user message templates replaces $do_search = array( '$+fname+$','$+lname+$','$+address1+$','$+address2+$','$+city+$','$+state+$','$+zip+$','$+hphone+$','$+wphone+$','$+email+$','$+message_text+$','$+search_engine+$','$+ptstore+$','$+friend+$','$+other+$','$+agreem+$','$+add_info+$'); $do_replace = array($_POST['fname'],$_POST['lname'],$_POST['address1'],$_POST['address2'],$_POST['city'],$_POST['state'],$_POST['zip'],$_POST['hphone'],$_POST['wphone'],$_POST['email'],$_POST['message_text'],$_POST['search_engine'],$_POST['ptstore'],$_POST['friend'],$_POST['other'],$_POST['agreem'],$_POST['add_info']); //Send user email? if($SEND_THANKS == 1){ $user_message = str_replace($do_search,$do_replace,$USER_TEMPLATE); //Set Headers $user_header = "Return-Path: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">\r\n"; $user_header .= "From: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">\r\n"; $user_header .= "Content-Type: ".$EMAIL_OPTIONS['TYPE']."; charset=".$EMAIL_OPTIONS['CHARSET'].";\n\n\r\n"; //Send Thank you mail ($_POST['email'],$EMAIL_OPTIONS['USER_SUBJECT'],$user_message,$user_header); } //Send admi email? if(count($ADMIN_EMAILS) > 0){ $admin_message = str_replace($do_search,$do_replace,$ADMIN_TEMPLATE); //Do we need to send file as attachment? if($FILE_DO != 1){ //Get file attriubtes $fileatt_type = $_FILES['user_file']['type']; $file = fopen($FILE_UPLOADS_DIR.$new_filename,'rb'); while($dat = fread($file,1025657)){ $attachment_data .= $dat; } fclose($file); // Encode file content $attachment_data = chunk_split(base64_encode($attachment_data)); //File upload headers $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers = "From: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">"; // Add the headers for a file attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // Add a multipart boundary above the plain message $new_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: ".$EMAIL_OPTIONS['TYPE']."; charset=\"".$EMAIL_OPTIONS['CHARSET']."\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $admin_message . "\n\n"; // Add file attachment to the message $new_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$new_filename}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$new_filename}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $attachment_data . "\n\n" . "--{$mime_boundary}--\n"; unset($attachment_data); } else { //regular headers $headers = "Return-Path: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">\r\n"; $headers .= "From: ".$EMAIL_OPTIONS['TITLE']." <".$EMAIL_OPTIONS['FROM'].">\r\n"; $headers .= "Content-Type: ".$EMAIL_OPTIONS['TYPE']."; charset=".$EMAIL_OPTIONS['CHARSET'].";\n\n\r\n"; $new_message = $admin_message; } //Send admin emails foreach($ADMIN_EMAILS as $this_email){ mail ($this_email,$EMAIL_OPTIONS['ADMIN_SUBJECT'],$new_message,$headers); } } //Remove file if not needed //if($FILE_DO == 2){ // unlink($FILE_UPLOADS_DIR.$new_filename); // } $message = 'Your contact has been sent, thank you.'; $_POST = NULL; } } if($message != NULL){ ?> <center> <table width="500" border="0" cellpadding="5" cellspacing="0" bgcolor="#ffffff"> <tr> <td bgcolor="#FFD5D5" align="center"><font color="#FF0000"><b><?=$message;?></b></font></td> </tr> </table></center> <br/> <?php } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="contact" id="contact" style="display:inline;"> <table width="620" border="0" cellpadding="5" cellspacing="0" class="btext"> <tr> <td align="center" colspan="2"><img src="../images/pvt.jpg" alt="Poverello Thrift Store" border="0"></td> </tr> <tr> <td align="left" colspan="2">Thank you for donating to The Poverello Thrift Stores. Please fill out the form below to make an online donation pick-up request, Poverello Thrift Store representative will contact you within the next 48-hour by phone.<br> Note: Poverello Thrift Stores donation pick-up's are made only within the Fort Lauderdale and Wilton Manor, metropolitan areas. Donation pick-up's are made 5 days a week between 9am and 2pm. Pick-up availability depends on pick-up location and time. </td> </tr> <tr> <td align="center" colspan="2">All fields with (<b>*</b>) must be completed.<br> If you are using anti-spam software, please allow emails from Poverello.org to be received. </td> </tr> <tr> <td>Title:</td> <td> <select name="ttitle" id="ttitle" style="width:50px;"> <?php if($_POST['ttitle'] == 'Mr' || $_POST['ttitle'] == NULL){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Mr"<?=$sel;?>>Mr</option> <?php if($_POST['ttitle'] == 'Mrs'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Mrs"<?=$sel;?>>Mrs</option> <?php if($_POST['ttitle'] == 'Miss'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Miss"<?=$sel;?>>Miss</option> <?php if($_POST['ttitle'] == 'Ms'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Ms<?=$sel;?>">Ms</option> <?php if($_POST['ttitle'] == 'Dr'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="Dr<?=$sel;?>">Dr</option> </select> * </td> </tr> <tr> <td>First Name:</td> <td><input name="fname" type="text" id="fname" value="<?php echo $_POST['fname'];?>"> *</td> </tr> <tr> <td>Last Name:</td> <td><input name="lname" type="text" id="lname" value="<?php echo $_POST['lname'];?>"> *</td> </tr> <tr> <td>Address:</td> <td><input maxlength="100" size="50" name="address1" type="text" id="address1" value="<?php echo $_POST['address1'];?>"> *</td> </tr> <tr> <td>Address:</td> <td><input maxlength="100" size="50" name="address2" type="text" id="address2" value="<?php echo $_POST['address2'];?>"></td> </tr> <tr> <td>City:</td> <td><input name="city" type="text" id="city" value="<?php echo $_POST['city'];?>"> *</td> </tr> <tr> <td>State:</td> <td> <select name="state" id="state" style="width:50px;"> <?php if($_POST['state'] == 'AL' || $_POST['state'] == NULL){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="AL"<?=$sel;?>>AL</option> <?php if($_POST['state'] == 'AK'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="AK"<?=$sel;?>>AK</option> <?php if($_POST['state'] == 'AZ'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="AZ"<?=$sel;?>>AZ</option> <?php if($_POST['state'] == 'AR'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="AR<?=$sel;?>">AR</option> <?php if($_POST['state'] == 'CA'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="CA<?=$sel;?>">CA</option> <?php if($_POST['state'] == 'CO'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="CO<?=$sel;?>">CO</option> <?php if($_POST['state'] == 'CT'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="CT<?=$sel;?>">CT</option> <?php if($_POST['state'] == 'DE'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="DE<?=$sel;?>">DE</option> <?php if($_POST['state'] == 'DC'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="DC<?=$sel;?>">DC</option> <?php if($_POST['state'] == 'FL'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="FL<?=$sel;?>">FL</option> <?php if($_POST['state'] == 'GA'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="GA<?=$sel;?>">GA</option> <?php if($_POST['state'] == 'HI'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="HI<?=$sel;?>">HI</option> <?php if($_POST['state'] == 'ID'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="ID<?=$sel;?>">ID</option> <?php if($_POST['state'] == 'IL'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="IL<?=$sel;?>">IL</option> <?php if($_POST['state'] == 'IN'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="IN<?=$sel;?>">IN</option> <?php if($_POST['state'] == 'IA'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="IA<?=$sel;?>">IA</option> <?php if($_POST['state'] == 'KS'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="KS<?=$sel;?>">KS</option> <?php if($_POST['state'] == 'KS'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="KS<?=$sel;?>">KS</option> <?php if($_POST['state'] == 'KY'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="KY<?=$sel;?>">KY</option> <?php if($_POST['state'] == 'LA'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="LA<?=$sel;?>">LA</option> <?php if($_POST['state'] == 'ME'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="ME<?=$sel;?>">ME</option> <?php if($_POST['state'] == 'MD'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="MD<?=$sel;?>">MD</option> <?php if($_POST['state'] == 'MA'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="MA<?=$sel;?>">MA</option> <?php if($_POST['state'] == 'MI'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="MI<?=$sel;?>">MI</option> <?php if($_POST['state'] == 'MN'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="MN<?=$sel;?>">MN</option> <?php if($_POST['state'] == 'MS'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="MS<?=$sel;?>">MS</option> <?php if($_POST['state'] == 'MO'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="MO<?=$sel;?>">MO</option> <?php if($_POST['state'] == 'MT'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="MT<?=$sel;?>">MT</option> <?php if($_POST['state'] == 'NC'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="NC<?=$sel;?>">NC</option> <?php if($_POST['state'] == 'ND'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="ND<?=$sel;?>">ND</option> <?php if($_POST['state'] == 'NE'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="NE<?=$sel;?>">NE</option> <?php if($_POST['state'] == 'NH'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="NH<?=$sel;?>">NH</option> <?php if($_POST['state'] == 'NJ'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="NJ<?=$sel;?>">NJ</option> <?php if($_POST['state'] == 'NM'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="NM<?=$sel;?>">NM</option> <?php if($_POST['state'] == 'NV'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="NV<?=$sel;?>">NV</option> <?php if($_POST['state'] == 'NY'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="NY<?=$sel;?>">NY</option> <?php if($_POST['state'] == 'OH'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="OH<?=$sel;?>">OH</option> <?php if($_POST['state'] == 'OK'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="OK<?=$sel;?>">OK</option> <?php if($_POST['state'] == 'OR'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="OR<?=$sel;?>">OR</option> <?php if($_POST['state'] == 'PA'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="PA<?=$sel;?>">PA</option> <?php if($_POST['state'] == 'RI'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="RI<?=$sel;?>">RI</option> <?php if($_POST['state'] == 'SC'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="SC<?=$sel;?>">SC</option> <?php if($_POST['state'] == 'SD'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="SD<?=$sel;?>">SD</option> <?php if($_POST['state'] == 'TN'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="TN<?=$sel;?>">TN</option> <?php if($_POST['state'] == 'TX'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="TX<?=$sel;?>">TX</option> <?php if($_POST['state'] == 'UT'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="UT<?=$sel;?>">UT</option> <?php if($_POST['state'] == 'VT'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="VT<?=$sel;?>">VT</option> <?php if($_POST['state'] == 'VA'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="VA<?=$sel;?>">VA</option> <?php if($_POST['state'] == 'WA'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="WA<?=$sel;?>">WA</option> <?php if($_POST['state'] == 'WV'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="WV<?=$sel;?>">WV</option> <?php if($_POST['state'] == 'WI'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="WI<?=$sel;?>">WI</option> <?php if($_POST['state'] == 'WY'){ $sel = ' selected';} else { $sel = NULL;} ?> <option value="WY<?=$sel;?>">WY</option> </select> * </td> </tr> <tr> <td>Zip Code:</td> <td><input maxlength="10" size="10"name="zip" type="text" id="zip" value="<?php echo $_POST['zip'];?>"> *</td> </tr> <tr> <td>Home Phone:</td> <td><input name="hphone" type="text" id="hphone" value="<?php echo $_POST['hphone'];?>"> *</td> </tr> <tr> <td>Business Phone:</td> <td><input name="wphone" type="text" id="wphone" value="<?php echo $_POST['wphone'];?>"> (optional)</td> </tr> <tr> <td>Email:</td> <td><input name="email" type="text" id="email" value="<?php echo $_POST['email'];?>"> *</td> </tr> <tr> <td valign="top">List Description of items to pick-up:</td> <td><textarea name="message_text" cols="40" rows="4" id="message_text"><?php echo $_POST['message_text'];?></textarea> *</td> </tr> <tr> <td valign="top">How did you hear about the Poverello website?</td> <td><input type="radio" value="<?php echo $_POST['Search'];?>" name="about" id="search_engine" >Search engine (Google, yahoo, etc.)<br /> <input type="radio" value="<?php echo $_POST['Store'];?>" name="about" id="ptstore">Poverello Thrift Store<br /> <input type="radio" value="<?php echo $_POST['Friend'];?>" name="about" id="friend" >A Friend<br /> Other: <input name="other" type="text" id="other" value="<?php echo $_POST['other'];?>"> </td> </tr> <tr> <td colspan="2">Disclaimer: Please note that The Poverello Center does not guarantee you a donation item pick-up by filling out this form. All pick-up items are required to be in saleable condition and must meet the Poverello Center saleable condition standard. The condition of all items to be donated, size of the donation item(s) and pick-up location are considered before any donation pick-up is scheduled.</td> </tr> <tr> <td colspan="2" > <input type="checkbox" value="Agreement" name="agreem[]" id="agreem"> I have read and agree to the above Disclaimer terms</td> </tr> <tr> <td colspan="2"><input type="checkbox" value="Add" name="agreem[]" id="add_info"> Yes, send me addiotional information such as annoucements, special events, and more.</td> </tr> <tr> <td colspan="2"><div align="center"> <input type="submit" name="Submit" value="Send Contact"> <input name="submit_id" type="hidden" id="submit_id" value="1"> </div></td> </tr> </table> </form> <?php /* +++++++++++++++++++++++++++++++++++++ END Contact FILE ---------------------------------------*/ ?> Quote Link to comment 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.