I've been palying around with a script I've found on the internet, adapting it to my needs and everythng is working except when I try to add some drop down boxes.
I know how to add them in the "html" part, but don't know how to make them work with this script.
The "var" I've used is "tipo".
Thanks in advance!
COMPLETE PHP THAT I INCLUDE IN ANOTHER PHP
<?php if (session_id() == '') session_start(); /******************************************************************************* * Title: Easy PHP Contact Form (Non Captcha Version) * Version: 2.0 @ September 14, 2010 * Author: Vishal P. Rao * Website: http://www.easyphpcontactform.com ******************************************************************************** * COPYRIGHT NOTICE * Copyright 2010 Vishal P. Rao. All Rights Reserved. * * This script may be used and modified free of charge by anyone * AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT. * By using this code you agree to indemnify Vishal P. Rao or * www.easyphpcontactform.com from any liability that might arise from * it's use. * * Selling the code for this program, in part or full, without prior * written consent is expressly forbidden. * * Obtain permission before redistributing this software over the Internet * or in any other medium. In all cases copyright and header must remain * intact. This Copyright is in full effect in any country that has * International Trade Agreements with the India * * Removing any of the copyright notices without purchasing a license * is illegal! *******************************************************************************/ /******************************************************************************* * Script configuration - Refer README.txt *******************************************************************************/ echo "<link rel=stylesheet href=../scripts/index.css>"; include_once "formfiles/contact-config.php"; $error_observacoes = ''; if (!isset($_POST['submit'])) { showForm(); } else { //form submitted $error = 0; if(!empty($_POST['check'])) die("Invalid form access"); if(!empty($_POST['name'])) { $name[2] = clean_var($_POST['name']); } else { $error = 1; $name[3] = 'color:#FF0000;'; $name[4] = '<span style="campos">Obrigatório</span>'; } if(!empty($_POST['idade'])) { $idade[2] = clean_var($_POST['idade']); if (function_exists('htmlspecialchars')) $idade[2] = htmlspecialchars($idade[2], ENT_QUOTES); } else { $error = 1; $idade[3] = 'color:#FF0000;'; } if(!empty($_POST['postal'])) { $postal[2] = clean_var($_POST['postal']); if (function_exists('htmlspecialchars')) $postal[2] = htmlspecialchars($postal[2], ENT_QUOTES); } else { $error = 1; $postal[3] = 'color:#FF0000;'; } if(!empty($_POST['fax'])) { $fax[2] = clean_var($_POST['fax']); if (function_exists('htmlspecialchars')) $fax[2] = htmlspecialchars($fax[2], ENT_QUOTES); } else { $error = 1; $fax[3] = 'color:#FF0000;'; } if(!empty($_POST['tipo'])) { $tipo[2] = clean_var($_POST['tipo']); if (function_exists('htmlspecialchars')) $tipo[2] = htmlspecialchars($tipo[2], ENT_QUOTES); } else { $error = 1; $tipo[3] = 'color:#FF0000;'; } if(!empty($_POST['telefone'])) { $telefone[2] = clean_var($_POST['telefone']); if (function_exists('htmlspecialchars')) $telefone[2] = htmlspecialchars($telefone[2], ENT_QUOTES); } else { $error = 1; $telefone[3] = 'color:#FF0000;'; } if(!empty($_POST['email'])) { $email[2] = clean_var($_POST['email']); if (!validEmail($email[2])) { $error = 1; $email[3] = 'color:#FF0000;'; $email[4] = '<strong><span style="color:#FF0000;">Email inválido</span></strong>'; } } else { $error = 1; $email[3] = 'color:#FF0000;'; } if(!empty($_POST['morada'])) { $morada[2] = clean_var($_POST['morada']); if (function_exists('htmlspecialchars')) $morada[2] = htmlspecialchars($morada[2], ENT_QUOTES); } else { $error = 1; $morada[3] = 'color:#FF0000;'; } if(!empty($_POST['observacoes'])) { $observacoes[2] = clean_var($_POST['observacoes']); if (function_exists('htmlspecialchars')) $observacoes[2] = htmlspecialchars($observacoes[2], ENT_QUOTES); } if(empty($_POST['security'])) { $error = 1; $security[3] = 'color:#FF0000;'; } else { if($question_answers[$_POST['question']] != strtolower(clean_var($_POST['security']))) { $error = 1; $security[3] = 'color:#FF0000;'; $security[4] = '<strong><span style="color:#FF0000;">Wrong answer</span></strong>'; } } if ($error == 1) { $error_observacoes = '<span style="font-weight:bold;font-size:90%;">Por favor preencha os campos obrigatórios.</span>'; showForm(); } else { if (function_exists('htmlspecialchars_decode')) $morada[2] = htmlspecialchars_decode($morada[2], ENT_QUOTES); if (function_exists('htmlspecialchars_decode')) $observacoes[2] = htmlspecialchars_decode($observacoes[2], ENT_QUOTES); if (function_exists('htmlspecialchars_decode')) $telefone[2] = htmlspecialchars_decode($telefone[2], ENT_QUOTES); if (function_exists('htmlspecialchars_decode')) $fax[2] = htmlspecialchars_decode($fax[2], ENT_QUOTES); if (function_exists('htmlspecialchars_decode')) $postal[2] = htmlspecialchars_decode($postal[2], ENT_QUOTES); if (function_exists('htmlspecialchars_decode')) $idade[2] = htmlspecialchars_decode($idade[2], ENT_QUOTES); if (function_exists('htmlspecialchars_decode')) $tipo[2] = htmlspecialchars_decode($tipo[2], ENT_QUOTES); $body .= "$name[0]: $name[2]\r\n\r\n"; $body .= "$email[0]: $email[2]\r\n\r\n"; $body .= "$idade[0]: $idade[2]\r\n\r\n"; $body .= "$telefone[0]: $telefone[2]\r\n\r\n"; $body .= "$postal[0]: $postal[2]\r\n\r\n"; $body .= "$fax[0]: $fax[2]\r\n\r\n"; $body .= "$tipo[0]: $tipo[2]\r\n\r\n"; $body .= "$observacoes[0]:\r\n$observacoes[2]\r\n\r\n"; if (!$from) $from_value = $email[2]; else $from_value = $from; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/plain; $charset" . "\r\n"; $headers .= "From: $from_value" . "\r\n"; $headers .= "Reply-To: $email[2]" . "\r\n"; mail($to,"$morada_prefix - $morada[2]", $body, $headers); $_POST['security'] = ''; if (!$thank_you_url) { if ($use_header_footer) include $header_file; echo '<a name="cform"><!--Form--></a>'."\n"; echo '<div id="formContainer" style="width:'.$form_width.';height:'.$form_height.';text-align:left; vertical-align:top;">'."\n"; echo $GLOBALS['thank_you_observacoes']."\n"; echo '</div>'."\n"; if ($use_header_footer) include $footer_file; } else { header("Location: $thank_you_url"); } session_unset(); session_destroy(); } } //else submitted function showForm() { global $name, $idade, $morada, $postal, $telefone, $fax, $email, $tipo, $observacoes, $security, $question_answers; global $where_included, $use_header_footer, $header_file, $footer_file; global $form_width, $form_height, $form_background, $form_border_color, $form_border_width, $form_border_style, $cell_padding, $left_col_width; if ($use_header_footer) include $header_file; $question = array_rand($question_answers); echo $GLOBALS['error_observacoes']; echo <<<EOD <a name="cform"><!--Form--></a> <div id="formContainer" style="width:{$form_width};"> <p style="text-align:left; vertical-align:middle; padding:{$cell_padding}; font-size:90%; font-weight:bold;">* campos obrigatórios</p> <form method="post" class="cForm" action="{$where_included}#cform"> <p> <div style="width:450px; height:{$form_height}; padding:10px;" id="contactForm"> <p><label for="name">{$name[0]}</label><input type="text" name="{$name[1]}" value="{$name[2]}" id="{$name[1]}" class="input" />{$name[4]}</p> <p><label for="idade">{$idade[0]}</label><input type="text" name="{$idade[1]}" value="{$idade[2]}" id="{$idade[1]}" class="input_pequeno" />{$idade[4]}</p> <p><label for="morada">{$morada[0]}</label><input type="text" class="input" name="{$morada[1]}" value="{$morada[2]}" id="{$morada[1]}" /></p> <p><label for="postal">{$postal[0]}</label><input type="text" class="input" name="{$postal[1]}" value="{$postal[2]}" id="{$postal[1]}" /></p> <p><label for="telefone">{$telefone[0]}</label><input type="text" class="input" name="{$telefone[1]}" value="{$telefone[2]}" id="{$telefone[1]}" /></p> <p><label for="fax">{$fax[0]}</label><input type="text" class="input" name="{$fax[1]}" value="{$fax[2]}" id="{$fax[1]}" /></p> <p><label for="email">{$email[0]}</label><input type="text" class="input" name="{$email[1]}" value="{$email[2]}" id="{$email[1]}" /> {$email[4]}</p> <p><label for="tipo">{$tipo[0]}<span class="campos">*</span></label><select id="tipo" name="select"> <option value="1">Casamento</option> <option value="2">Congresso</option> <option value="3">Evento</option> </select></p> <p><label for="observacoes">{$observacoes[0]}</label><textarea name="{$observacoes[1]}" cols="40" rows="6" class="textarea" id="{$observacoes[1]}">{$observacoes[2]}</textarea></p> <p style="width:{$left_col_width}; text-align:left; vertical-align:top; padding:{$cell_padding}; font-weight:bold; {$security[3]}">{$question}?</p> <p style="text-align:left; vertical-align:top; padding:{$cell_padding};"><input type="text" name="{$security[1]}" value="" id="{$security[1]}" /> {$security[4]} <br /><br />We are sorry but please answer the above question to prove you are a real visitor and not a spam bot.</p> <p style="text-align:left; vertical-align:middle; padding:{$cell_padding};"><input type="submit" name="submit" value="Submit" style="border:1px solid #999;background:#E4E4E4;margin-top:5px;" id="submit_button" /></p> </div> <input type="hidden" name="question" value="{$question}"> <input type="hidden" name="check" value=""> </form> <!-- Removing the attribution link without obtaining a licence is illegal and prohibited --> <!-- Check out Branding Removal option at http://www.easyphpcontactform.com/ --> <div style="width:100%;text-align:right;font-size:80%;margin-top: 0;"> <a href="http://www.easyphpcontactform.com/" title="PHP Contact Form" target="_blank">PHP Contact Form</a> </div> </div> EOD; if ($use_header_footer) include $footer_file; } function clean_var($variable) { $variable = strip_tags(stripslashes(trim(rtrim($variable)))); return $variable; } /** Email validation function. Thanks to http://www.linuxjournal.com/article/9585 */ function validEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } if ($isValid && function_exists('checkdnsrr')) { if (!(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))) { // domain not found in DNS $isValid = false; } } } return $isValid; } ?>
ANOTHER COMPLETE PHP THAT'S CONNECTED TO THE FIRST ONE
<?php /******************************************************************************* * Title: Easy PHP Contact Form (Non Captcha Version) * Version: 2.0 @ September 14, 2010 * Author: Vishal P. Rao * Website: http://www.easyphpcontactform.com ******************************************************************************** * COPYRIGHT NOTICE * Copyright 2010 Vishal P. Rao. All Rights Reserved. * * This script may be used and modified free of charge by anyone * AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT. * By using this code you agree to indemnify Vishal P. Rao or * www.easyphpcontactform.com from any liability that might arise from * it's use. * * Selling the code for this program, in part or full, without prior * written consent is expressly forbidden. * * Obtain permission before redistributing this software over the Internet * or in any other medium. In all cases copyright and header must remain * intact. This Copyright is in full effect in any country that has * International Trade Agreements with the India * * Removing any of the copyright notices without purchasing a license * is illegal! *******************************************************************************/ /******************************************************************************* * Script configuration - Refer README.txt *******************************************************************************/ /******************************************************************************* * IMPORTANT *******************************************************************************/ /* Email address where the observacoess should be delivered */ $to = '[email protected]'; /* This will be appended to the morada of contact form observacoes */ $morada_prefix = 'Formulário Pré-Reserva'; /* name of the file where you are including the contact form */ $where_included = 'reserva_teste.php'; /******************************************************************************* * OPTIONAL *******************************************************************************/ /* Security question and answer array */ $question_answers = array ( 'Moon is red or white' => 'white', 'Sun is blue or yellow' => 'yellow', 'Fire is hot or cold' => 'hot', 'Icecream is hot or cold' => 'cold' ); /* From email address, in case your server prohibits sending emails from * addresses other than those of your own domain (e.g. [email protected]). */ $from = ''; /* Whether to use header/footer files? If yes, then set to TRUE */ $use_header_footer = FALSE; /* Form header file */ $header_file = 'formfiles/contact-header.php'; /* Form footer file */ $footer_file = 'formfiles/contact-footer.php'; /* Thank you observacoes to be displayed after the form is submitted. Can include * HTML tags. Write your observacoes between <!-- Start observacoes --> and <!-- End observacoes --> */ $thank_you_observacoes = <<<EOD <!-- Start observacoes --> <p><strong>Obrigada pelo seu contacto. Iremos analizar o seu evento e entraremos em contacto consigo brevemente.</strong></p> <!-- End observacoes --> EOD; /* URL to be redirected to after the form is submitted. If this is specified, * then the above observacoes will not be shown and user will be redirected to this * page after the form is submitted. */ $thank_you_url = ''; /* Default character encoding of emails */ $charset = 'charset=UTF-8'; /******************************************************************************* * COSMETICS *******************************************************************************/ /* Form width in px or % value */ $form_width = '90%'; /* Form height in px */ $form_height = '800px'; /* Form background color or image. Value can contain just a color value or * complete background shorthand property (with background image). */ $form_background = '#F7F8F7'; /* Form border color */ $form_border_color = '#CCCCCC'; /* Form border width */ $form_border_width = '1px'; /* Form border style. Examples - dotted, dashed, solid, double */ $form_border_style = 'solid'; /* Form cell padding */ $cell_padding = '5px'; /* Form left column width */ $left_col_width = '25%'; /******************************************************************************* * Do not change anything below, unless of course you know very well * what you are doing <img src='http://www.pixel2life.com/forums/public/style_emoticons/<#EMO_DIR#>/smile.gif' class='bbc_emoticon' alt=':)' /> *******************************************************************************/ $name = array('Name','name',NULL,NULL); $idade = array('Idade','idade',NULL,NULL); $morada = array('Morada','morada',NULL,NULL); $postal = array('Postal','postal',NULL,NULL); $telefone = array('Telefone','telefone',NULL,NULL); $fax = array('Fax','fax',NULL,NULL); $tipo = array('Tipo','tipo',NULL,NULL); $email = array('Email','email',NULL,NULL,NULL); $observacoes = array('Observacoes','observacoes',NULL,NULL); $security = array('Security question','security',NULL,NULL,NULL); ?>
Edited by whoopic, 01 August 2011 - 06:25 PM.