pues como me comentaste Gordot, intenté seguir el tutorial ese, pero en ese tutorial daban por sentado que ya sabrías del tema y si copiabas y pegabas el código tal cual, no funcionaba porque había de "embedarse" algo que no sé hacer y que explicaban en otro tutorial. Y no hay manera...
Mi formulario original es:
Código PHP:
<form method="post" enctype="multipart/form-data" action="processor.php" onsubmit="return validatePage1();">
<p>
<label class="formFieldQuestion">
· Contact name: <br />
</label>
<input class="mainForm" type="text" name="field_1" id="field_1" size='30' value='' />
<label class="formFieldQuestion"><br />
<br />
· Phone number: <br />
</label>
<input class="mainForm" type="phone" name="field_2" id="field_2" size="25" value="" style="background-image:url(imgs/phone.png); background-repeat: no-repeat; padding: 2px 2px 2px 25px;" />
</p>
<p>
<label class="formFieldQuestion">· Email: <br />
</label>
<input class="mainForm" type="email" name="field_3" id="field_3" size="25" value="" style="background-image:url(imgs/email.png); background-repeat: no-repeat; padding: 2px 2px 2px 25px;" />
</p>
<p>
<label class="formFieldQuestion">· Numer of people<br />
</label>
<input class="mainForm" type="text" name="field_4" id="field_4" size='30' value='' />
</p>
<p>
<label class="formFieldQuestion">· Type of service: <br />
</label>
<select class="mainForm" name="field_5" id="field_5">
<option value=''></option>
<option value="Girona">Girona</option>
<option value="Sitges">Sitges</option>
<option value="Montserrat + Cavas Penedes">Montserrat + Cavas Penedes</option>
<option value="Cavas Penedes">Cavas Penedes</option>
<option value="Montserrat Tour">Montserrat Tour</option>
<option value="Modernism Tour">Modernism Tour</option>
<option value="Artistic Tour">Artistic Tour</option>
<option value="Walking Tour">Walking Tour</option>
<option value="City Tour Barcelona">City Tour Barcelona</option>
<option value="Transfer in/out">Transfer in/out</option>
<option value="Figueres (Dalí Museum)">Figueres (Dalí Museum)</option>
<option value="Tarragona">Tarragona</option>
<option value="Cadaques & Portlligat">Cadaques & Portlligat</option>
<option value="Other City Tour">Other City Tour</option>
<option value="Other Outside City Tour">Other Outside City Tour</option>
<option value="Other Service">Other Service</option>
</select>
</p>
<p>
<label class="formFieldQuestion">· Pick-up hour: <br />
</label>
<input class="mainForm" type="text" name="field_6" id="field_6" size='30' value='' />
</p>
<p>
<label class="formFieldQuestion">· Pick-up place:<br />
</label>
<input class="mainForm" type="text" name="field_7" id="field_7" size='30' value='' />
</p>
<p>
<label class="formFieldQuestion">· Explain your needs: <br />
</label>
<textarea class="mainForm" name="field_8" id="field_8" rows="5" cols="23"></textarea>
<script type="text/javascript">
<!--
function validatePage1()
{
retVal = true;
if (validateField('field_1','fieldBox_1','text',1) == false)
retVal=false;
if (validateField('field_2','fieldBox_2','phone',1) == false)
retVal=false;
if (validateField('field_3','fieldBox_3','email',1) == false)
retVal=false;
if (validateField('field_4','fieldBox_4','text',1) == false)
retVal=false;
if (validateField('field_5','fieldBox_5','menu',1) == false)
retVal=false;
if (validateField('field_6','fieldBox_6','text',1) == false)
retVal=false;
if (validateField('field_7','fieldBox_7','text',1) == false)
retVal=false;
if (validateField('field_8','fieldBox_8','textarea',1) == false)
retVal=false;
if(retVal == false)
{
alert('Please correct the errors. Fields marked with an asterisk (*) are required');
return false;
}
return retVal;
}
//-->
</script>
</p>
<p>
<input id="saveForm" class="mainForm" type="submit" value="Submit" />
</p>
</form>
Al que le hice un código php muy muy sencillo:
Código PHP:
<?php
$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
mail("[email protected]","Day Tours Barcelona Contac & Booking","Form data:
· Contact name:: " . $_POST['field_1'] . "
· Phone number:: " . $_POST['field_2'] . "
· Email:: " . $_POST['field_3'] . "
· Numer of people: " . $_POST['field_4'] . "
· Kind of service: : " . $_POST['field_5'] . "
· Hour of pick up:: " . $_POST['field_6'] . "
· Place of pick up:: " . $_POST['field_7'] . "
· Explain your needs: : " . $_POST['field_8'] . "
");
include("confirm.html");
?>
Pero al seguir el tutorial que me dijiste intenté hacer una mezcla para respetar mi formulario sin tener que hacer otro, pero nada no pude... y yo que sé, por lógica hice esto:
Código PHP:
<?php
if(isset($_POST['submit']))
{
if(empty($_SESSION['6_letters_code'] ) ||
strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
{
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()
$errors .= "\n The captcha code does not match!";
}
if(empty($errors))
{
//send the email
$to = $your_email;
$subject="New form submission";
$from = $your_email;
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
"$body = "A user $_POST['field_1'] submitted the contact form:n".
" · Contact Name: $_POST['field_1']n".
" · Phone Number: $_POST['field_2'] n".
" · Email: $_POST['field_3'] n".
" · Number of people: $_POST['field_4'] n".
" · Kind of service: $_POST['field_5'] n".
" · Hour of pick up: $_POST['field_6'] n".
" · Place of pick up: $_POST['field_7'] n".
" · Needs: n ".
"$_POST['field_8']n".
"IP: $ipn";
$headers = "From: $from rn";
$headers .= "Reply-To: $visitor_email rn";
mail($to, $subject, $body,$headers);
header('Location: confirm.html');
}
}
?>
Pero no porque sepa hacerlo, solo fui comparando cosas y con "suposiciones" pensé que sería así pero al contrario, es evidente que no sé nada de nada y de lógica no va esto jeje.