Cannot POST / contact_process.php - php

i've tried to create this contact form and here is the HTML code:
<section class="contact_info_area sec_pad bg_color">
<div class="container">
<div class="row">
<div class="col-lg-3 pr-0">
<div class="contact_info_item">
<h6 class="f_p f_size_20 t_color3 f_500 mb_20">Información de contacto</h6>
<p class="f_400 f_size_15"><span class="f_400 t_color3">Email:</span> admin#doupmedia.com</p>
</div>
</div>
<div class="col-lg-8 offset-lg-1">
<div class="contact_form">
<form action="contact_process.php" class="contact_form_box" method="post" id="contactForm" novalidate="novalidate">
<div class="row">
<div class="col-lg-6">
<div class="form-group text_box">
<input type="text" id="name" name="name" placeholder="Tu Nombre">
</div>
</div>
<div class="col-lg-6">
<div class="form-group text_box">
<input type="text" name="email" id="email" placeholder="Correo Electrónico">
</div>
</div>
<div class="col-lg-12">
<div class="form-group text_box">
<input type="text" id="subject" name="subject" placeholder="Asunto">
</div>
</div>
<div class="col-lg-12">
<div class="form-group text_box">
<input type="text" id="subject" name="subject" placeholder="Teléfono">
</div>
</div>
<div class="col-lg-6">
<div class="form-group text_box">
<input type="text" id="subject" name="subject" placeholder="Página Web de la Empresa">
</div>
</div>
<div>
<script>
$('.calendar').flatpickr({
locale:"es",
minDate: "today",
"disable": [
function(date) {
// return true to disable
return (date.getDay() === 0 || date.getDay() === 6);
}
],
"locale": {
"firstDayOfWeek": 1 // start week on Monday
}
})
</script>
</div>
<div>
<label for="country">Tamaño de clientes aproximado</label>
<select id="clientes" name="country">
<option value="australia">0 - 1k</option>
<option value="canada">1k - 10k</option>
<option value="usa">100k - 1M</option>
<option value="usa">1M - 10M</option>
</select>
<label for="country">¿A qué hora va bien que te llamemos?</label>
<select id="clientes" name="country">
<option value="australia">10:00 - 11:00</option>
<option value="canada">11:00 - 12:00</option>
<option value="usa">12:00 - 13:00</option>
<option value="usa">13:00 - 14:00</option>
<option value="usa">16:00 - 17:00</option>
<option value="usa">17:00 - 18:00</option>
<option value="usa">18:00 - 19:00</option>
<option value="usa">19:00 - 20:00</option>
</select>
</div>
<div class="col-lg-12">
<div class="form-group text_box">
<textarea name="message" id="message" cols="30" rows="10" placeholder="Deja tu mensaje..."></textarea>
</div>
</div>
</div>
<div class="custom-control custom-switch custom-switch-light">
<input type="checkbox" class="custom-control-input" id="customSwitch2" required="">
<label class="custom-control-label" for="customSwitch2">He leído y acepto la política de privacidad y protección de datos.</label>
</div>
<br>
<button type="submit" class="btn_three" >Enviar Mensaje</button>
</form>
<div id="success">¡En breves nos pondremos en contacto contigo!</div>
<div id="error">Opps! Ha habido un error. Porfavor inténtelo de nuevo.</div>
</div>
</div>
</div>
</div>
</section>
And when I try to edit the contact.php which is called contact_process.php it jumps a white page with thhat error: Cannot POST / contact_process.php
If somebody knows the answer please help.
<?php
$to = "runjiebusiness#gmail.com";
$from = $_REQUEST['email'];
$name = $_REQUEST['name'];
$name2 = $_REQUEST['name2'];
$csubject = $_REQUEST['subject'];
$cmessage = $_REQUEST['message'];
$headers = "From: $from";
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$subject = "You have a message from your Doup Media.";
$logo = '';
$link = '#';
$body = "<!DOCTYPE html><html lang='en'><head><meta charset='UTF-8'><title>Bixcoin Master Mail</title></head><body>";
$body .= "<table style='width: 100%;'>";
$body .= "<thead style='text-align: center;'><tr><td style='border:none;' colspan='2'>";
$body .= "<a href='{$link}'><img src='{$logo}' alt=''></a><br><br>";
$body .= "</td></tr></thead><tbody><tr>";
$body .= "<td style='border:none;'><strong>Name:</strong> {$name}</td>";
$body .= "<td style='border:none;'><strong>Email:</strong> {$from}</td>";
$body .= "</tr>";
$body .= "<tr><td style='border:none;'><strong>Subject:</strong> {$csubject}</td></tr>";
$body .= "<tr><td></td></tr>";
$body .= "<tr><td colspan='2' style='border:none;'>{$cmessage}</td></tr>";
$body .= "</tbody></table>";
$body .= "</body></html>";
$send = mail($to, $subject, $body, $headers);
?>

the _REQUEST variable is missing the field "name2". so the PHP script fails:
$name2 = $_REQUEST['name2'];
This means you need to add an input in your form for name2 or remove this in your PHP script.

Related

Input radio not sending data

I have a simple contact form, the html is this part:
<!-- CONTACT FORM -->
<form id="contact-form" name="contactform" class="row">
<!-- CONTACT FORM IMPUT -->
<div id="input_name" class="col-md-12">
<input type="text" name="name" id="name" class="form-control" placeholder="Il tuo nome">
</div>
<div id="input_email" class="col-md-12">
<input type="text" name="email" id="email" class="form-control" placeholder="Email">
</div>
<div id="input_subject" class="col-md-12">
<input type="text" name="subject" id="subject" class="form-control" placeholder="Numero di telefono">
</div>
<div id="input_message" class="col-md-12">
<textarea class="form-control" name="message" id="message" rows="6" placeholder="Il tuo messaggio..."></textarea>
</div>
<div class="col-md-12 sinistra"><br>Quale servizio ti interessa?<br><br></div>
<div class="col-md-4 sinistra">
<input type="radio" name="tipologia" value="standard"> Standard<br>
</div>
<div class="col-md-4 sinistra">
<input type="radio" name="tipologia" value="avanzato"> Avanzato<br>
</div>
<div class="col-md-4 sinistra">
<input type="radio" name="tipologia" value="deluxe"> Deluxe<br>
</div>
<div class="col-md-12"><br></div>
<!-- CONTACT FORM SUBMIT BUTTON -->
<div id="form_btn" class="col-md-12">
<input type="submit" value="Invia" id="submit" class="btn btn-small btn-blue">
</div>
<!-- CONTACT FORM MESSAGE -->
<div class="col-md-12 contact-form-msg">
<span class="loading"></span>
</div>
</form>
with this php file
<?
$name = $_REQUEST["name"];
$email = $_REQUEST["email"];
$subject = $_REQUEST["subject"];
$msg = $_POST["msg"];
$tipologia = $_POST['tipologia'] ;
$to = "info#gmail.com";
if (isset($email) && isset($name) && isset($msg) ) {
$email_subject = "$name ha inviato una richiesta di ordine";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "Da: ".$name." <".$email.">\r\n"."Reply-To: ".$email."\r\n" ;
$msg = "Da: $name<br/> Email: $email <br/> Telefono: $subject <br/>
Tipologia: $tipologia <br/> Messaggio: $msg";
$mail = mail($to, $email_subject, $msg, $headers);
if($mail)
{
echo 'success';
}
else
{
echo 'failed';
}
}
?>
but I have a problem with radio input, the form works but doesn't pass the value of radio to email, so the email has the Tipologia without the radio selected for the form... What could be the error?
<form> defaults to a GET method if POST isn't implied.
You're using two POST arrays.
So... use a POST method and all POST arrays.
Either way, everything must match.
You should also check if the radio buttons are set or not, or any other you wish to include.

Sending selected option value to email with php

I want the customer to pick different options from a dropdown, and then display the selected option in an email after they have submitted a form. It is supposed to send an email to me and the customer. Right now it's not sending the value from the select.
I have the following code:
<?php
if(isset($_POST['submit'])){
$to = "myemail#myemail.com"; // this is your Email address
$from = $_POST['email_address']; // this is the sender's Email address
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$address_street = $_POST['address_street'];
$phone = $_POST['phone_no'];
$quantity = $_POST['quantity'];
$select = $_POST['select'];
$subject = "Write the subject here";
$subject2 = "Write the subject here";
$message = "You have selected:" . "\n\n" . "" . $phone . $_POST['quantity'] . $_POST['select'] . $_POST['address_street'];
$message2 = "you have selected:" . "\n\n" . "" . $_POST['quantity'] . $_POST['select'] . $_POST['address_street'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Din mail er sendt " . $first_name . " " . $last_name . " " . ". Du har valgt følgende vinduer: " . $select;
}
?>
<form action="" method="POST">
<div class="row">
<div class="large-3 medium-6 small-12 columns">
<img class="windows" src="http://spejlblank.nu/wp-content/uploads/2016/03/SPEJLBLANK_INTERIOR_V036_ENKELTFAG.jpg" width="385" height="385" alt="">
<div class="dropdown-option">
<select id="select" name="select">
<option value="" selected>VÆLG POLERINGSTYPE</option>
<option value="30">INDVENDIG + UDVENDIG</option>
<option value="60">UDVENDIG</option>
<option value="90">INDVENDIG</option>
<option value="90">FORSATS (INKL. INDVENDIG + UDVENDIG)</option>
</select>
</div>
<div class="quantity-field">
<input type="number" name="quantity" min="0" max="100" placeholder="STK.">
</div>
</div>
<div class="row contact-form-pris">
<h3 style="text-transform: uppercase;">Indtast dine oplysninger og modtag dit uforpligtende tilbud!</h3>
<div class="large-6 small-12 columns">
<label for="first_name">Fornavn *</label>
<input class="" name="first_name" id="first_name" type="text" required/>
</div>
<div class="large-6 small-12 columns">
<label for="last_name">Efternavn *</label>
<input class="" name="last_name" id="last_name" type="text" required/>
</div>
<div class="large-12 columns">
<label for="address_street">Adresse *</label>
<input class="" name="address_street" id="address_street" type="text" required/>
</div>
<div class="large-6 small-12 columns">
<label for="email_address">Email *</label>
<input class="" name="email_address" id="email_address" type="email" required/>
</div>
<div class="large-6 small-12 columns">
<label for="mobile_no">Telefon *</label>
<input class="" name="mobile_no" id="mobile_no" type="tel" required/>
</div>
<div class="large-12 columns text-center">
<input type="submit" name="submit" value="MODTAG UFORPLIGTENDE TILBUD" class="submit-pris">
</div>
</div>
</form>
Try this in your drop down
<select id="select" name="select">
<option value="VÆLG POLERINGSTYPE" selected>VÆLG POLERINGSTYPE</option>
<option value="INDVENDIG + UDVENDIG">INDVENDIG + UDVENDIG</option>
<option value="UDVENDIG">UDVENDIG</option>
<option value="INDVENDIG">INDVENDIG</option>
<option value="FORSATS (INKL. INDVENDIG + UDVENDIG)">FORSATS (INKL. INDVENDIG + UDVENDIG)</option>
</select>
In your first option you were sending blank value and other values were numbers which you probably don't want to show to make email meaningful.
Change
<option value="" selected>VÆLG POLERINGSTYPE</option>
to
<option value="" >VÆLG POLERINGSTYPE</option>

Getting no info from Contact Form

This is my html code:
<form id="main-contact-form" name="contact-form" method="post" action="php/sendemail.php">
<div class="row wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms">
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="Nombre Completo" required="">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="email" name="email" class="form-control" placeholder="Correo Electronico" required="">
</div>
</div>
</div>
<div class="form-group">
<input type="text" name="phone" class="form-control" placeholder="Numero de telefono" required="">
</div>
<div class="form-group">
<input type="text" name="section" class="form-control" placeholder="Grado & Sección" required="">
</div>
<div class="form-group">
<input type="text" name="subject" class="form-control" placeholder="Subjeto" required="">
</div>
<div class="form-group">
<textarea name="txt" id="message" class="form-control" rows="4" placeholder="Mensaje" required=""></textarea>
</div>
<div class="form-group">
<button type="submit" name="submit12" class="btn-submit">Enviar ahora</button>
</div>
</form>
and this is my php one:
<?php
$subjectm = $_POST['subject'];
$txt = $_POST['txt'];
$section = $_POST['section'];
$email = $_POST['email'];
$name = $_POST['name'];
$phone = $_POST['phone'];
$to = "soporte#colegiolavictoria.holixgaming.com";
$subject = "".$subjectm." | Solicitud de Soporte - Colegio La Victoria";
$headers = "From: " . $email . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "CC: soporte#colegiolavictoria.holixgaming.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "
<html>
<head>
<title>".$subjectm." | Solicitud de Soporte - Colegio La Victoria</title>
</head>
<body>
<h3><b>Nombre:</b> </h3><h5>".$name."</h5>\n \n \n</br>
<h3><b>Grado y sección: </h3><h5></b>".$section." <b>\n \n \n</br></h5>
<h3><b>Correo Electronico:</b> </h3><h5>".$email."\n \n \n</br></h5>
<h3><b>Numero de Telefono:</b> </h3><h5>".$phone."\n \n \n</br></h5>
<h3><b>Mensaje: </b></h3><h5>".$txt."\n \n \n</br></h5>
<h2>Este es un mensaje automatizado, favor de no contestar al mismo.</h2>
</body>
</html>
";
mail($to, $subject, $message, $headers);
?>
so, the problem is: when i hit the send button, i get the email but its empty (is getting info from index.php to sendemail.php), i tryied everything but i cant fix it.
This is the message im getting on my mail:
Nombre:
Grado y sección:
Correo Electronico:
Numero de Telefono:
Mensaje:
Este es un mensaje automatizado, favor de no contestar al mismo.
(Obviusly its empty)
I couldn't find the exact issue with your code but I found success by combining the two files into one as seen in the following code.
<?php if ( !empty($_POST) )
{
$subjectm = $_POST['subject'];
$message = $_POST['message'];
$section = $_POST['section'];
$email = $_POST['email'];
$name = $_POST['name'];
$phone = $_POST['phone'];
$to = "soporte#colegiolavictoria.holixgaming.com";
$subject = "".$subjectm." | Solicitud de Soporte - Colegio La Victoria";
$headers = "From: " . $email . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "CC: soporte#colegiolavictoria.holixgaming.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "
<html>
<head>
<title>".$subjectm." | Solicitud de Soporte - Colegio La Victoria</title>
</head>
<body>
<h3><b>Nombre:</b> </h3><h5>".$name."</h5>\n \n \n</br>
<h3><b>Grado y sección: </h3><h5></b>".$section." <b>\n \n \n</br></h5>
<h3><b>Correo Electronico:</b> </h3><h5>".$email."\n \n \n</br></h5>
<h3><b>Numero de Telefono:</b> </h3><h5>".$phone."\n \n \n</br></h5>
<h3><b>Mensaje: </b></h3><h5>".$message."\n \n \n</br></h5>
<h2>Este es un mensaje automatizado, favor de no contestar al mismo.</h2>
</body>
</html>
";
mail($to, $subject, $message, $headers);
}
?>
<form id="main-contact-form" name="contact-form" method="post" action="">
<div class="row wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms">
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="Nombre Completo" required="">
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="email" name="email" class="form-control" placeholder="Correo Electronico" required="">
</div>
</div>
</div>
<div class="form-group">
<input type="text" name="phone" class="form-control" placeholder="Numero de telefono" required="">
</div>
<div class="form-group">
<input type="text" name="section" class="form-control" placeholder="Grado & Sección" required="">
</div>
<div class="form-group">
<input type="text" name="subject" class="form-control" placeholder="Subjeto" required="">
</div>
<div class="form-group">
<textarea name="message" id="message" class="form-control" rows="4" placeholder="Mensaje" required=""></textarea>
</div>
<div class="form-group">
<button type="submit" name="submit" class="btn-submit">Enviar ahora</button>
</div>
</form>
I'm guessing that it has something to do with how you are declaring the headers. Try running this, as it's a bit cleaner, and works on my dev machine:
<?php
$subjectm = $_POST['subject'];
$message = $_POST['message'];
$section = $_POST['section'];
$email = $_POST['email'];
$name = $_POST['name'];
$phone = $_POST['phone'];
$to = "soporte#colegiolavictoria.holixgaming.com";
$subject = "$subjectm | Solicitud de Soporte - Colegio La Victoria";
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/html; charset=iso-8859-1";
$headers[] = "From: {$email}";
$headers[] = "CC: {$to}";
$headers[] = "Reply-To: {$email}";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
$message = "
<html>
<head>
<title>$subject</title>
</head>
<body>
<h3><b>Nombre:</b> </h3><h5>$name</h5>\n \n \n</br>
<h3><b>Grado y sección: </h3><h5></b>$section<b>\n \n \n</br></h5>
<h3><b>Correo Electronico:</b> </h3><h5>$email \n \n \n</br></h5>
<h3><b>Numero de Telefono:</b> </h3><h5>$phone \n \n \n</br></h5>
<h3><b>Mensaje: </b></h3><h5>$message \n \n \n</br></h5>
<h2>Este es un mensaje automatizado, favor de no contestar al mismo.</h2>
</body>
</html>";
mail($to, $subject, $message, implode("\r\n", $headers));
?>

Getting my AJAX/PHP contact form to send email

I've looked at various solutions but I just can't get my contact form to work. **The issue im having is that the email wont actually send out to me, everything works client side but I dont get the email. So I have come here to surely get the duplicate question label. Here is my code:
<form method="post" class="reply" id="contact" action="process.php">
<fieldset>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<label>Name: <span>*</span></label>
<input class="form-control" id="name" name="name" type="text" value="" required>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<label>Email: <span>*</span></label>
<input class="form-control" type="email" id="email" name="email" value="" required>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<label>Subject: <span>*</span></label>
<input class="form-control" id="subject" name="subject" type="text" value="" required>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<label>Message: <span>*</span></label>
<textarea class="form-control" id="text" name="text" rows="3" cols="40" required></textarea>
</div>
</div>
</fieldset>
<button class="btn btn-normal btn-color submit bottom-pad" type="submit">Send</button>
<div class="success alert-success alert" style="display:none">Your message has been sent successfully.</div>
<div class="error alert-error alert" style="display:none">E-mail must be valid and message must be longer than 100 characters.</div>
<div class="clearfix">
</div>
</form>
Here is my process.php
<?php
// Email Submit
// Note: filter_var() requires PHP >= 5.2.0
if ( isset($_POST['email']) && isset($_POST['name']) && isset($_POST['subject']) && isset($_POST['text']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {
// detect & prevent header injections
$test = "/(content-type|bcc:|cc:|to:)/i";
foreach ( $_POST as $key => $val ) {
if ( preg_match( $test, $val ) ) {
exit;
}
}
// PREPARE THE BODY OF THE MESSAGE
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['name']) . "</td></tr>";
$message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>";
$message .= "<tr><td><strong>Message:</strong> </td><td>" . htmlentities($_POST['text']) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
// CHANGE THE BELOW VARIABLES TO YOUR NEEDS
$to = 'iknowichange#this.com';
$subject = $_POST['subject'];
$headers = "From: " . $_POST['email'] . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers);
}
?>
I am completely new to forms, so thanks in advance for the help. If there are any resources that you can suggest that would be great. Thanks!
It looks like you just forgot to include an action in your form element.
(Unless your binding an onsubmit event somewhere else)
Try
<form method="post" class="reply" id="contact" action="process.php">
You haven't set any action in your form element. You've to set the path of your "process.php" in form element like following:
<form action="process.php" method="post" id="contact" class="reply">
...
</form>
More about form: http://www.w3schools.com/html/html_forms.asp

Can't get my php form working, sends mail but doesn't run code on redirect page

This question gets asked all the time, but I can't figure out why mine isn't working. I have a form that redirects to itself. If PHP decides it is submitted, there is a success/failure message and it displays the user input as the default value and disables the fields: using phpinfo I can see that the form is being submitted, but this first conditional doesn't work. I've tried a couple of versions, but no luck. It's weird because it sends the email
Specifically, the result and disable functions don't display their code after the form has been sent.
<?php
function clean($data) {
$data = trim(stripslashes(strip_tags($data)));
return $data;
}
function result(){
if($sent) echo $result;
}
function disable($field){
if($sent){
if($field != null){
$ret .= $field . '", disabled, placeholder!="';
}
$ret .= '", disabled, placeholder!="';
echo $ret;
}
}
function option($item){
$ret = "<option>";
if($sent){
if($eventType == $item){
$ret = "<option selected>";
}
}
$ret .= $item . "</option>";
echo $ret;
}
if(isset($_POST['name'])){
$sent = TRUE;
$result = null;
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$eventDate = $_POST['eventDate'];
$eventTime = $_POST['eventTime'];
$eventLength = $_POST['eventLength'];
$eventLocation = $_POST['eventLocation'];
$eventType = $_POST['eventType'];
$message = $_POST['message'];
$recipient = "";
$subject = " Form Submission";
$mailheader = "From: \r\n";
$formcontents = "You received this e-mail message through your website: \n\n";
$formcontents .= "Name: " . clean($name) . "\r\n";
$formcontents .= "Phone: " . clean($phone) . "\r\n";
$formcontents .= "Email: " . clean($email) . "\r\n";
$formcontents .= "Event Date: " . clean($eventDate) . "\r\n";
$formcontents .= "Event Time: " . clean($eventTime) . "\r\n";
$formcontents .= "Event Length: " . clean($eventLength) . "\r\n";
$formcontents .= "Event Location: " . clean($eventLocation) . "\r\n";
$formcontents .= "Event Type: " . clean($eventType) . "\r\n";
$formcontents .= "Message: " . clean($message) . "\r\n";
$formcontents .= "\r\n";
$formcontents .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n";
$formcontents .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n";
// Send mail
if(mail($recipient, $subject, $formcontents, $mailheader)){;
$result = '<h3 class="alert alert-success"> Thank you, your form was successfully sent and I will contact you shortly.</h3>';
} else {
$result = '<h3 class="alert alert-error"> Your mail could not be sent at this time.</h3>';
}
}
?>
<form action="contact.php" method="POST" class="form-horizontal span4">
<fieldset>
<legend>
<h2>Or send me a message. </h2>
</legend>
<p class="help-block">None of the fields are required, but the more information I have about your event, the more detailed I can be in my response.</p>
<legend class="help-block">Your Details</legend>
<div class="control-group">
<label for="name" class="control-label">Your Name</label>
<div class="controls">
<input id="name" type="text" name="name" placeholder="<?php disable($name); ?>" class="input-xlarge"/>
</div>
</div>
<div class="control-group">
<label for="phone" class="control-label">Your Contact Number</label>
<div class="controls">
<input id="phone" type="tel" name="phone" placeholder="<?php disable($phone); ?>" class="input-xlarge"/>
</div>
</div>
<div class="control-group">
<label for="email" class="control-label">Your Email</label>
<div class="controls">
<input id="email" type="email" name="email" placeholder="<?php disable($email); ?>" class="input-xlarge"/>
</div>
</div>
<legend class="help-block">Your Event </legend>
<div class="control-group">
<label for="eventDate" class="control-label">Your Event's Date</label>
<div class="controls">
<input id="eventDate" type="date" name="eventDate" placeholder="<?php disable($eventDate); ?>" class="input-xlarge"/>
</div>
</div>
<div class="control-group">
<label for="eventTime" class="control-label">Your Event's Start Time</label>
<div class="controls">
<input id="eventTime" type="time" name="eventTime" placeholder="<?php disable($eventTime); ?>" class="input-xlarge"/>
</div>
</div>
<div class="control-group">
<label for="eventLength" class="control-label">Your Event's Length</label>
<div class="controls">
<input id="eventLength" type="text" name="eventLength" placeholder="<?php disable($eventLength); ?>" class="input-xlarge"/>
</div>
</div>
<div class="control-group">
<label for="eventLocation" class="control-label">Your Event's Location</label>
<div class="controls">
<input id="eventLocation" type="text" name="eventLocation" placeholder="<?php disable($eventLocation); ?>" class="input-xlarge"/>
</div>
</div>
<div class="control-group">
<label for="eventType" class="control-label">What Kind of Event</label>
<div class="controls">
<select id="eventType" name="eventType" placeholder="<?php disable($eventType); ?>"><?php option("Charity Event"); option("Expo/Trade Show"); option("Personal Event"); option("Other"); ?></select>
</div>
</div>
<div class="control-group">
<label for="message" class="control-label">Other comments or the best time to reach you.</label>
<div class="controls">
<textarea id="message" name="message" rows="10" placeholder="<?php disable($message); ?>" class="input-xxlarge"></textarea>
</div>
</div>
<div class="form-actions">
<button type="submit" name="submit" placeholder="<?php disable(null); ?>" class="btn btn-primary">Send Message</button>
</div>
</fieldset>
</form>
You have to import your global variables into function scope, like:
function result(){
global $sent, $result;
if($sent) echo $result;
}
..in functions disable() and option(), too.
if(isset($_POST['name'])){
should be
if(isset($_POST['submit'])){

Categories