Not receiving mails even after successful POST - php

I got a mailscript which works, I tested it before.
Now all of a sudden with the same code I am not receiving any mails, nor are other people.
I looked in spam and inbox on both outlook and gmail.
This is my mail script:
<?PHP
require_once ('config.php');
require_once("../phpMailer/class.phpmailer.php");
$isValid = true;
if(isset($_POST['name']) && isset($_POST['subject']) && isset($_POST['email']) && isset($_POST['message']))
{
$name = $_POST['name'];
$subject = 'Er is een contact aanvraag op Kijk & Zie : '.$_POST['subject'];
$email = $_POST['email'];
$message = $_POST['message'];
$phone = $_POST['phone'];
$mail = new PHPMailer;
$mail->From = $email;
$mail->FromName = $name;
$mail->addAddress("receiver#live.nl"); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject;
$texts = 'Er is een aanvraag op de website van Kijk & Zie<br /> <br />
<b>Naam:</b> '.$name.'<br />
<b>E-mail adres:</b> '.$email.'<br />
<b>Onderwerp:</b> '.$subject.'<br />
<b>Telefoonnummer:</b>'.$phone.'<br />
<b>Vragen / Opmerkingen:</b> '.$message.'<br /><br /><br />
';
$handtekening = '
<table border="0" width="100%" cellspacing="0" cellpadding="0" style="font-family:calibri;color: #5C5C5C; font-size:10pt;line-height:22px;">
<tr>
<td width="160" valign="top" style="font-family:calibri;padding-left:10px;padding-top:20px;">
[contents]
</td>
</tr>
<tr>
<td width="160" valign="top" style="font-family:calibri;padding-left:10px;padding-top:20px;">
<br><br>Met vriendelijke groet,<br><br>
Helpdesk<br>
<b>Kijk & Zie</b><br>
<p></p>
</td>
</tr>
</table>
<table height="120" border="0" width="100%" cellspacing="0" cellpadding="0" style="font-family:calibri;color: #5C5C5C; font-size:10pt;line-height:22px;">
<tr>
<td width="250" valign="top" style="font-family:calibri;padding-left:10px;padding-top:20px;border-top: 1px #000000 dotted; border-bottom: 1px #000000 dotted;">
E:
info#website.nl<br>
T:
(0181) 851 859<br>
W:
www.website.nl<br>
</td>
<td align="right" style="font-family:calibri;padding-right:10px;padding-top:5px;border-top: 1px #000000 dotted; border-bottom: 1px #000000 dotted;">
<a href="http://website.nl/" target="_blank" title="Ga naar de website">
<img src="http://www.website-kindercoaching.nl" alt="Ga naar de website" style="font-family:calibri;text-align:right;margin:0px;padding:10px 0 10px 0;" border="0" width="232">
</a>
</td>
</tr>
<tr>
<td colspan="2" style="font-family:calibri;color:#a3a3a3;font-size:11px;margin-top:6px;line-height:14px;">
<br>Dit e-mailbericht is uitsluitend bestemd voor de geadresseerde. Als dit bericht niet voor u bestemd is, wordt u vriendelijk verzocht dit aan de afzender te melden. Kijk & Zie staat door de elektronische verzending van dit bericht niet in voor de juiste en volledige overbrenging van de inhoud, noch voor tijdige ontvangst daarvan. Voor informatie over Kijk & Zie raadpleegt u Kijk & Zie.<br><br>
</td>
</tr>
</table>';
$contents = preg_replace('/\[contents]/',$texts, $handtekening);
$mail->msgHTML($contents);
$mail->AltBody = $texts;
if(!$mail->send())
{
$isValid = false;
}
$mail = new PHPMailer;
$mail->From = 'info#website.nl';
$mail->FromName = 'Kijk & Zie';
$mail->addAddress($email); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Bedankt voor uw aanvraag bij Kijk & Zie';
$texts = 'Geachte heer/mevrouw '.$naam.',<br /><br />
Hartelijk dank voor uw aanvraag bij Kijk & Zie<br />
Wij reageren zo spoedig mogelijk op uw aanvraag.<br /><br />
Uw gegevens worden nooit aan derden ter hand gesteld.
';
$contents = preg_replace('/\[contents]/',$texts, $handtekening);
$mail->msgHTML($contents);
$mail->AltBody = $texts;
if(!$mail->send())
$isValid = false;
}
if($isValid == true) {
$result["submit_message"] = _msg_send_ok;
} else {
$result["submit_message"] = _msg_send_error;
}
$array = array(
'isValid' => $isValid
);
echo json_encode($result);
This is the ajax code in case someone needs it:
//contact form
if($(".contact-form").length)
{
$(".contact-form").each(function(){
$(this)[0].reset();
});
$(".submit-contact-form").on("click", function(event){
event.preventDefault();
$("#contact-form").submit();
});
}
$(".contact-form").submit(function(event){
event.preventDefault();
var data = $(this).serializeArray();
var self = $(this);
//if($(this).find(".total-cost").length)
// data.push({name: 'total-cost', value: $(this).find(".total-cost").val()});
self.find(".block").block({
message: false,
overlayCSS: {
opacity:'0.3',
"backgroundColor": "#FFF"
}
});
$.ajax({
url: self.attr("action"),
data: data,
type: "post",
dataType: "json",
success: function(json){
self.find(".submit-contact-form, [name='submit'], [name='name'], [name='email'], [name='message']").qtip('destroy');
if(typeof(json.isOk)!="undefined" && json.isOk)
{
if(typeof(json.submit_message)!="undefined" && json.submit_message!="")
{
self.find(".submit-contact-form").qtip(
{
style: {
classes: 'ui-tooltip-success'
},
content: {
text: json.submit_message
},
position: {
my: "right center",
at: "left center"
}
}).qtip('show');
self[0].reset();
self.find(".cost-slider-input").trigger("change");
self.find(".cost-dropdown").selectmenu("refresh");
self.find("input[type='text'], textarea").trigger("focus").trigger("blur");
}
}
else
{
if(typeof(json.submit_message)!="undefined" && json.submit_message!="")
{
self.find(".submit-contact-form").qtip(
{
style: {
classes: 'ui-tooltip-error'
},
content: {
text: json.submit_message
},
position: {
my: "right center",
at: "left center"
}
}).qtip('show');
}
if(typeof(json.error_name)!="undefined" && json.error_name!="")
{
self.find("[name='name']").qtip(
{
style: {
classes: 'ui-tooltip-error'
},
content: {
text: json.error_name
},
position: {
my: "bottom center",
at: "top center"
}
}).qtip('show');
}
if(typeof(json.error_email)!="undefined" && json.error_email!="")
{
self.find("[name='email']").qtip(
{
style: {
classes: 'ui-tooltip-error'
},
content: {
text: json.error_email
},
position: {
my: "bottom center",
at: "top center"
}
}).qtip('show');
}
if(typeof(json.error_message)!="undefined" && json.error_message!="")
{
self.find("[name='message']").qtip(
{
style: {
classes: 'ui-tooltip-error'
},
content: {
text: json.error_message
},
position: {
my: "bottom center",
at: "top center"
}
}).qtip('show');
}
}
self.find(".block").unblock();
}
});
});
What could it be that's preventing me from receiving/sending any emails?
When I submit the form it gives me a success message, and in the serverlog I can see it is posted succesfully.

Related

Erro com PHPMailer - Fatal error: Class 'PHPMailer' not found in /home/intergroup/public_html/view/envio_contato.php on line 90

This is the message i am getting on my log.
Fatal error: Class 'PHPMailer' not found in
/home/intergroup/public_html/view/envio_contato.php on line 90
But when i press crtl+g on sublime he finds the classes with means the includes are correct.
this is my code: (This text right here is just because StackOverflor dont allows me to post my question, he says i have too much code and i need to explain better and give more details, so: How can i solve this problem, like, what kind of actions can i take to debug?)
<?php
$robots = 'nao';
include '_definicoes.php';
include_once '_header.php';
$pagina_atual = 'envio_contato';
$link_encaminhar_erro = $dominio;
$link_encaminhar_concluido = $dominio;
$title = $nome_site;
$description = $description;
$keywords = $keywords;
// resposta vazia
$response = null;
// verifique a chave secreta
// $reCaptcha = new ReCaptcha($secret);
// if (isset($_POST['submit'])) {
// se submetido, verifique a resposta
// if ($_POST["g-recaptcha-response"]) {
// $response = $reCaptcha->verifyResponse(
// $_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]
// );
// }
// if ($response == null) {
// echo "<script>alert('Por favor assinale o campo de verificação!');history.back();</script>";
// exit;
// }
// Verifica a resposta do Captcha
if ($response != null && $response->success) {
$nome_site_utf8 = utf8_decode($nome_site);
$nome_contato = utf8_decode($_POST['nome_contato']);
$email_contato = $_POST['email_contato'];
$telefone_contato = $_POST['telefone_contato'];
$assunto_contato_utf8 = utf8_decode($_POST['assunto_contato']);
$mensagem_contato = utf8_decode(nl2br($_POST['mensagem_contato']));
$link_anterior = $_POST['link_anterior'];
//checando se o e-mail é válido
$email_contato = strtolower($email_contato);
$qtd_email = explode("#", $email_contato);
if (count($qtd_email) <= 1) {
//se não possuir # aparece a mensagem
echo "<script>alert('Por favor, insira um e-mail válido!');history.back();</script>";
exit;
} else if (count($qtd_email) == 2) {
$ip = gethostbyname($qtd_email[1]);
//função gethostbyname recupera o ip do domínio, se não tiver ip aparece a mensagem
if ($ip == $qtd_email[1]) {
echo "<script>alert('Por favor, insira um e-mail válido!');history.back();</script>";
exit;
}
}
if ($assunto_contato_utf8 == '') {
echo "<script>alert('Por favor, preencha um Assunto!');history.back();</script>";
exit;
}
$nome_contato = ucwords(strtolower($nome_contato));
$email_conteudo = "<html>
<body>
<font face='Arial' style='color: #606060;'>
<table border='0' style='width: 400px;>
<tr> <td style='height: 40px; text-align: left; font-size: 14px; color: #606060;'> <b>Assunto:</b><br/> $assunto_contato_utf8<br/><br/> </td> </tr>
<tr> <td style='height: 40px; text-align: left; font-size: 14px; color: #606060;'> <b>Nome:</b><br/> $nome_contato<br/> </td> </tr>
<tr> <td style='height: 40px; text-align: left; font-size: 14px; color: #606060;'> <b>E-mail:</b><br/> $email_contato<br/> </td> </tr>
<tr> <td style='height: 40px; text-align: left; font-size: 14px; color: #606060;'> <b>Telefone:</b><br/> $telefone_contato<br/> </td> </tr>
<tr> <td style='text-align: left; font-size: 14px; color: #606060;'> <b>Mensagem:</b><br/> $mensagem_contato<br/> </td> </tr>
<tr> <td style='height: 20px;'></td> </tr>
<tr> <td style='height: 40px; text-align: left; font-size: 14px; color: #606060;'> <b>Página de Referência:</b><br/> $link_anterior<br/> </td> </tr>
<tr> <td style='padding-top: 20px;'></td> </tr>
</table>
</font>
</body>
</html>";
/** Montagem e Envio do e-mail * */
date_default_timezone_set('Etc/UTC');
include 'phpmailer/class.phpmailer.php';
include 'phpmailer/class.smtp.php';
require 'phpmailer/PHPMailerAutoload.php';
}
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
//$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = $mail_host;
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = $mail_port;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = $mail_user;
//Password to use for SMTP authentication
$mail->Password = $mail_pass;
//Set who the message is to be sent from
$mail->setFrom("$mail_send", "$nome_contato");
//Set an alternative reply-to address
$mail->addReplyTo("$email_contato", "$nome_contato");
//Set who the message is to be sent to
$mail->addAddress("$email_formulario", "$nome_site_utf8");
$mail->addAddress("suporte#cgdw.com.br,suporte1#cgdw.com.br");
//$mail->addAddress("$email_formulario2", "$nome_site");
//Set the subject line
$mail->Subject = $assunto_contato_utf8 . " - ".$nome_site_utf8;
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->Body = $email_conteudo;
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "<script>alert('Desculpe, ocorreu um erro ao enviar, tente novamente!');window.open('" . $link_encaminhar_erro . "', '_self');</script>";
exit;
} else {
echo "<script>alert('Sua mensagem foi enviada, agradecemos seu contato!');window.open('" . $link_encaminhar_concluido . "', '_self');</script>";
exit;
}
?>
i solve the problem this way :
Delete ALL de old code (that was made for someone else) and star fresh. ending up with this code that work
<?php
if (isset($_POST['enviar'])) {
require_once 'phpmailer/PHPMailerT.class.php';
$json = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=6LfEGGoUAAAAAOQQe3y9EkneINSI9bEQLYOATrfr&response=' . $_POST['g-recaptcha-response']));
if (!is_object($json) || $json->success != true) {
echo "<script>alert('Por favor assinale o campo de verificação!');history.back();</script>";
}
$nome_contato = ($_POST['nome_contato']);
$telefone_contato = ($_POST['telefone_contato']);
$email_contato = ($_POST['email_contato']);
$assunto_contato = ($_POST['assunto_contato']);
$mensagem_contato = ($_POST['mensagem_contato']);
$Content = "
<p><b>Nome:</b> " . ($nome_contato) . "</p>
<p><b>Telefone:</b> " . ($telefone_contato) . "</p>
<p><b>Email:</b> " . ($email_contato) . "</p>
<p><b>Assunto:</b> " . ($assunto_contato) . "</p>
<p><b>Mensagem:</b> " . ($mensagem_contato) . "</p>";
$PHPMailer = new PHPMailerT();
$PHPMailer->IsSMTP();
$PHPMailer->SMTPAuth = true;
$PHPMailer->SMTPDebug = 1;
$PHPMailer->SMTPSecure = '';
$PHPMailer->Port = 587;
$PHPMailer->Host = 'mail.server.com.br';
$PHPMailer->Username = 'envio#server.com.br';
$PHPMailer->Password = '';
$PHPMailer->Subject = 'Contato do Site - Intergroup';
$PHPMailer->SetFrom($email_contato, $nome_contato);
$PHPMailer->AddAddress('contato#server.com.br');
$PHPMailer->AddAddress('suporte1#cgdw.com.br');
$ContentSend = "<table width=\"600\">";
$ContentSend .= "<tr>";
$ContentSend .= "<td>$Content<td>";
$ContentSend .= "</tr>";
$ContentSend .= "</table>";
$PHPMailer->MsgHTML($ContentSend);
if ($PHPMailer->Send()) {
echo "<script>alert('Mensagem enviada com sucesso.');history.back();</script>";
} else {
$msgReturn = '<div class="msgErro">Ocorreu um erro, tente mais tarde!</div>';
}
}
echo $msgReturn;
?>

My contact form is not sending emails

The contact form at the bottom of this page http://nmfnebbs.preview.infomaniak.website/
is not working, when I fill all the fields and I click on the button to send, the error message is displayed and nothing is sent to my Email.
Here is the script for the contact form:
var submitContact = $('#submit_contact'),
message = $('#msg');
submitContact.on('click', function(e){
e.preventDefault();
var $this = $(this);
$.ajax({
type: "POST",
url: 'contact.php',
dataType: 'json',
cache: false,
data: $('#contact-form').serialize(),
success: function(data) {
if(data.info !== 'error'){
$this.parents('form').find('input[type=text],textarea,select').filter(':visible').val('');
message.hide().removeClass('success').removeClass('error').addClass('success').html(data.msg).fadeIn('slow').delay(5000).fadeOut('slow');
} else {
message.hide().removeClass('success').removeClass('error').addClass('error').html(data.msg).fadeIn('slow').delay(5000).fadeOut('slow');
}
}
});
});
and here is the content of contact.php (except my email address)
/* ========================== Define variables ========================== */
#Your e-mail address
define("__TO__", "my email address");
#Message subject
define("__SUBJECT__", "IT-vip.com.tn");
#Success message
define('__SUCCESS_MESSAGE__', "Votre message a bien été envoyé");
#Error message
define('__ERROR_MESSAGE__', "Erreur, Votre message n'a pas été envoyé");
#Messege when one or more fields are empty
define('__MESSAGE_EMPTY_FILDS__', "Veuillez remplir tous les champs");
/* ======================== End Define variables ======================== */
//Send mail function
function send_mail($to,$subject,$message,$headers){
if(#mail($to,$subject,$message,$headers)){
echo json_encode(array('info' => 'success', 'msg' => __SUCCESS_MESSAGE__));
} else {
echo json_encode(array('info' => 'error', 'msg' => __ERROR_MESSAGE__));
}
}
//Check e-mail validation
function check_email($email){
if(!#eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
return false;
} else {
return true;
}
}
//Get post data
if(isset($_POST['name']) and isset($_POST['mail']) and isset($_POST['comment'])){
$name = $_POST['name'];
$mail = $_POST['mail'];
$website = $_POST['website'];
$comment = $_POST['comment'];
if($name == '') {
echo json_encode(array('info' => 'error', 'msg' => "Veuillez saisir votre nom"));
exit();
} else if($mail == '' or check_email($mail) == false){
echo json_encode(array('info' => 'error', 'msg' => "Veuillez saisir votre e-mail valide"));
exit();
} else if($comment == ''){
echo json_encode(array('info' => 'error', 'msg' => "Veuillez saisir votre message."));
exit();
} else {
//Send Mail
$to = __TO__;
$subject = __SUBJECT__ . ' ' . $name;
$message = '
<html>
<head>
<title>Mail from '. $name .'</title>
</head>
<body>
<table style="width: 500px; font-family: arial; font-size: 14px;" border="1">
<tr style="height: 32px;">
<th align="right" style="width:150px; padding-right:5px;">Name:</th>
<td align="left" style="padding-left:5px; line-height: 20px;">'. $name .'</td>
</tr>
<tr style="height: 32px;">
<th align="right" style="width:150px; padding-right:5px;">E-mail:</th>
<td align="left" style="padding-left:5px; line-height: 20px;">'. $mail .'</td>
</tr>
<tr style="height: 32px;">
<th align="right" style="width:150px; padding-right:5px;">Website:</th>
<td align="left" style="padding-left:5px; line-height: 20px;">'. $website .'</td>
</tr>
<tr style="height: 32px;">
<th align="right" style="width:150px; padding-right:5px;">Comment:</th>
<td align="left" style="padding-left:5px; line-height: 20px;">'. $comment .'</td>
</tr>
</table>
</body>
</html>
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: ' . $mail . "\r\n";
send_mail($to,$subject,$message,$headers);
}
} else {
echo json_encode(array('info' => 'error', 'msg' => __MESSAGE_EMPTY_FILDS__));
}
?>

Write text inside a < div > from an external function. PHP

Sorry if I have done wrong , is my first question on StackOverflow.
I want to write the value of var after doing several checks that are within the functions and as a result if everything is okey want to print the variables in a particular div. I have created three different div , one to display errors , one to show var and other one for the form.
What I Do That IS THIS:
https://mega.co.nz/#!3EQGQSAL!94ao1u6UhARYaYdjJzfFqY6ln1oPyO9JQ4_ElT7WEkA
Code:
<html>
<head>
<meta charset="UTF-8">
<title>Agenda Alex Ventura</title>
<style type="text/css">
#errores {
display: block;
background-color: grey;
border-color: red;
border-top-style: double;
border-right-style: double;
border-bottom-style: double;
border-left-style: double;
}
#contactos {
margin-top: 20px;
background-color: aquamarine;
}
#formulario{
margin-top: 50px;
}
</style>
</head>
<body>
<div id="errores">
<?php
if (!(isset($_POST['enviar']))) {
//Primera vez
$nombre = "";
$telefono = "";
} else {
if (errores()) {
//Segunda o siguientes veces con error
$nombre = "";
$telefono = "";
} else {
//Todo ok
$nombre = $_POST['nombre'];
$telefono = $_POST['telefono'];
imprimir_datos();
}
}
function errores() {
$nombre = $_POST['nombre'];
$telefono = $_POST['telefono'];
if ((empty($nombre)) || (empty($telefono))) {
echo "Los campos de usuariio y telefono no pueden estar vacíos";
return true;
}
if (strlen($telefono) < 9) {
echo "El telefono debe tener 9 digitos " . strlen($telefono);
return true;
}
if (strlen($telefono) > 9) {
echo "El telefono debe tener 9 digitos " . strlen($telefono);
return true;
}
$expresion = '[0-9]';
if (preg_match($expresion, $telefono) != true) {
echo "El telefono debe tener solo numeros " . ($telefono);
return true;
}
return false;
}
?>
</div>
<div id="contactos">
<?php
function imprimir_datos() {
$nombre = $_POST['nombre'];
$telefono = $_POST['telefono'];
echo "Nombre: $nombre, Telefono: $telefono</br>";
}
?>
</div>
<div id="formulario">
<form action=<?php echo $_SERVER['PHP_SELF'] ?> method="POST">
Nombre : <input type="text" name="nombre" value="<?php echo "$nombre"; ?>"/>
Telefono: <input type="text" name="telefono" value="<?php echo "$telefono"; ?>"/>`enter code here`
<input TYPE="submit" VALUE="Enviar" name="enviar"/>
</form>
</div>
</body>
https://mega.co.nz/#!CA5TmCQJ!utWGpH7PZwpPcHbDK3eTG6JMuTRz_Z6KKAFWtbqPm1o
oh, i see now. Patterns needs delimiters.
change this:
if (preg_match($expresion, $telefono) != true) {
to this:
if (preg_match("/" . $expresion . "/", $telefono) != true)
And for the printing the details, try this. Move the function outside from the div, and call it within the div.
<div id="contactos"><?php imprimir_datos(); ?></div>
<?php
function imprimir_datos() {
$nombre = $_POST['nombre'];
$telefono = $_POST['telefono'];
echo "Nombre: $nombre, Telefono: $telefono</br>";
}
?>

How to change VAR?

I've got a part of a PHP script, but it gives a T_CLASS error.
But i'm not sure how to convert the VAR element into a php5 compliant code...
Can somebody help me?
<?php // Defining the "calc" class
if (!class_exists('calc'))
class calc {
var $number1;
}
?>
p.s. this is just part of a bigger code, but it keeps saying: "PHP Syntax Check: Parse error: syntax error, unexpected T_CLASS in your code on line 3". So the error should be either in "class calc {" or in "var $number1;". Please help :P
I had to place the entire code. Just adding the brackets gave me a new error.
<?php // Defining the "calc" class
if (class_exists('calc')) {
class calc {
var $number1;
}
}
function boek($number1)
{
$result =$number1 * 2;
echo "Om een tekst van $number1 pagina's te redigeren, rekenen wij: <strong>€ $result,-*</strong></br>";
echo "<small>*Deze prijs is slechts een indicatie. Om een vrijblijvende offerte aan te vragen kunt u gebruikmaken van het contactformulier onderaan de pagina. <br/><span style=\"text-decoration: underline;\">Let op: studenten krijgen op vertoon van hun studentenpas 25% korting.</span></small>";
}
}
//Creating object of class
$calc = new calc();
?>
<style type="text/css">
.calcbutton {
Cursor: pointer;
display: block;
text-indent: -5000px;
width: 136px;
height: 44px;
border: none;
background-image: url('http://www.mijncreaties.com/wp-content/themes/GoedVerwoord/images/buttons.png');
background-repeat: no-repeat;
}
.calcbutton {background-position: top left;}
.calcbutton:hover {background-position: center left;}
.calcbutton:active {background-position: bottom left;}
</style>
<form name="calc" action="" method="POST">
<table>
<tr>
<td>Aantal pagina's: </td>
<td><input type="text" style="padding-left: 3px;" class="calc-form wpcf7-text" name="value1" value="0" onfocus="if (this.value == '0') {this.value = '';}" onblur="if (this.value == '') {this.value = '0';}"><br>
<input type="hidden" name="oper" value="boek">
</td>
</tr>
</table>
<input type="submit" value="Bereken prijs" name="submit" class="calcbutton">
</form>
<?
if($_POST['submit']){
$number1 = $_POST['value1'];
$oper = $_POST['oper'];
if(!$number1){
echo "<p><font color=\"red\">Vul a.u.b. een getal in.</font></p>";
}
if($oper == "boek"){
$calc->boek($number1);
}
}
?>
Try wrapping it in an extra set of braces:
<?php // Defining the "calc" class
if (!class_exists('calc')) {
class calc {
var $number1;
}
}
?>
Editted to add:
if (class_exists('calc')) {
class calc {
var $number1;
function boek($number1)
{
$result =$number1 * 2;
echo "Om een tekst van $number1 pagina's te redigeren, rekenen wij: <strong>€ $result,-*</strong></br>";
echo "<small>*Deze prijs is slechts een indicatie. Om een vrijblijvende offerte aan te vragen kunt u gebruikmaken van het contactformulier onderaan de pagina. <br/><span style=\"text-decoration: underline;\">Let op: studenten krijgen op vertoon van hun studentenpas 25% korting.</span></small>";
}
}
}
Your closing bracket was in the wrong place.
Wrap brackets around that if:
<?php
// Defining the "calc" class
if (!class_exists('calc')){
class calc {
var $number1;
}
}
?>
You will have the same issue when conditionally creating functions:
<?php
if (!function_exists('new_function')){
function new_function{
return 'awesome';
}
}
?>

IE8 Php header location opens a new window

I have a page dynamically filled with content from PHP and databases, the content is loaded into an iframe. Now when I make a custom search, the results are coming out fine on all browsers BUT IE8 (and maybe earlier versions). The browser sorts the results in a new window instead of filling the iframe!
my php search page:
<?php
if (isset($_REQUEST[searchname])) {
$searchname = $_REQUEST[searchname];
if (strlen($searchname) < 3) {
$location = "necrologies_iframe.php?action=tooshort";
header("Location: {$location}");
} else {
$location = "necrologies_iframe.php?action=search&nom={$searchname}";
header("Location: {$location}");
}
}
?>
Is there a way to fill the iframe with results instead of opening a new window?
Edit
The search form/button:
<form id="form1" name="form1" method="get" target="frame" action="http://www.cablevision.qc.ca/fr/code/necrologies_search.php">
<p><strong><a href="javascript:void(0);" onClick="necro_search('est');" >Abitibi-Est</a> | <!--//href="index.php?option=com_content&view=article&id=123&Itemid=146&action=est-->
<a href="javascript:void(0);" onClick="necro_search('ouest');" >Abitibi-Ouest</a> | <!--//href="index.php?option=com_content&view=article&id=123&Itemid=146&action=ouest"-->
<a href="javascript:void(0);" onClick="necro_search('rn');" >Rouyn-Noranda</a> | <!--//href="index.php?option=com_content&view=article&id=123&Itemid=146&action=rn"-->
Témiscamingue <!--//href="index.php?option=com_content&view=article&id=123&Itemid=146&action=temis"-->
</strong> |
<input name="searchname" type="text" id="searchname" value=<?php if (isset($_REQUEST[nom])) { echo '"' . $_REQUEST[nom] . '"'; } else { echo '"rechercher les archives"'; } ?> size="25" />
<input type="submit" name="submit" id="submit" value="Rechercher" />
The iframe part of the page
<iframe id="frame" "width="638px" frameborder="0" src="code/necrologies_iframe.php" scrolling="yes" horizontalscrolling="no" verticalscrolling="yes"></iframe>
the iframe page code
<style type="text/css">
<!--
table
{
line-height: 135%;
font-family: Arial, Helvetica, sans-serif;
font-size:13px;
}
.border {
border: 1px solid #000000;
}
.borderbas {
border-bottom: 1px solid #000000;
}
.padding {
padding: 5px;
}
-->
</style>
<?php
// fichier de connection a la DB
require_once("includes/connection.php");
require_once("includes/functions.php");
?>
<?php
$action = $_REQUEST[action];
$datedujour = date("Y-m-d");
switch ($action) {
case "search":
$searchname = utf8_decode(mysql_prep($_REQUEST[nom]));
$necroresult = mysql_query("SELECT * FROM necrologies WHERE nom LIKE '%{$searchname}%' AND approuve = '1' ORDER BY id DESC ");
if (mysql_affected_rows() == 0) {
// message que je fais afficher si il ne trouve rien (au lieu d'une page blanche qui ne veux rien dire
$message = "<br /><br /><br /><br /><h3>Aucun résultat trouvé </h3><br>Veuillez modifier le nom de la recherche...<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />";
} else {
// sinon on affiche le nombre de resultats trouvés
$necro_num_rows = mysql_num_rows($necroresult);
$message = $necro_num_rows . " résultat(s) trouvés...";
$affiche_liste = 1;
}
break;
case "tooshort":
echo "<br><br><center>Recherche trop courte, veuillez entrer plus de 4 caractères...</center><br><br><br><br><br><br><br><br><br><br><br><br><br>";
break;
case "est":
case "ouest":
case "rn":
case "temis":
$affiche_liste = 1; // pour faire afficher la liste des necro
$necroresult = mysql_query("SELECT * FROM necrologies WHERE datefin > '{$datedujour}' AND approuve = '1' AND region = '{$action}' ORDER BY id DESC ");
break;
default:
// default on vois toutes les necro de toute les regions
$necroresult = mysql_query("SELECT * FROM
necrologies WHERE datefin > '{$datedujour}' AND approuve = '1'
ORDER BY id DESC ");
$affiche_liste = 1;
}
?>
<br />
<?php
// affichage du message
if (isset($message)) {
echo "<br><strong><center>" . $message . "</strong></center><br>";
}
// liste des necro dans des tables
if ($affiche_liste == 1 || !isset($_REQUEST[action])) {
while ($row = mysql_fetch_array($necroresult)) {
?>
<!-- Debut de la table fancy round corner -->
<div align="center">
<table border="0" align="left" cellpadding="0" cellspacing="0" class="tb">
<tr>
<td width="16"><img src="/fr/images/roundtable/top_lef.gif" width="16" height="16"></td>
<td height="16" background="/fr/images/roundtable/top_mid.gif"><img src="/fr/images/roundtable/top_mid.gif" width="16" height="16"></td>
<td width="24"><img src="/fr/images/roundtable/top_rig.gif" width="24" height="16"></td>
</tr>
<tr>
<td width="16" background="/fr/images/roundtable/cen_lef.gif"><img src="/fr/images/roundtable/cen_lef.gif" width="16" height="11"></td>
<td align="center" valign="middle" bgcolor="#FFFFFF">
<!-- Debut du content de la table fancy round corner -->
<table width="576" border="0" cellspacing="0" cellpadding="0" class="border" >
<tr >
<td rowspan="2" valign="top"><img src="/fr/images/necrologies/<?php echo utf8_encode($row['photo']); ?>" alt="photo" /><br><img src="/fr/images/cnq/imprimable.gif" border="0" width="150" height="50"></td>
<td width="200" bgcolor="#DFEFFF" class="borderbas" style="border-left: 1px solid #000000; border-right: 1px solid #000000"><center><?php echo nl2br(mb_convert_encoding($row['nom'], "UTF-8", "Windows-1252")); ?></center></td>
<td bgcolor="#DFEFFF" class="borderbas">
<center>
<strong>
<?php
$maison = $row[maison];
if ($maison == "N/D") {
echo "(information non disponible)";
} else {
if (substr($maison, 0, 6) == "La dir") {
echo utf8_encode($maison);
} else {
echo "La direction des funérailles a été confiée à/aux <br>";
echo utf8_encode($maison);
}
}
?>
</strong></center></td>
</tr>
<tr>
<td style="border-left: 1px solid #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small;" colspan="2"><div class="padding" align="left"><?php echo nl2br(mb_convert_encoding($row['description'], "UTF-8", "Windows-1252")); ?></div></td>
</tr>
</table>
<!-- Fin du content de la table fancy round corner -->
</td>
<td width="24" background="/fr/images/roundtable/cen_rig.gif"><img src="/fr/images/roundtable/cen_rig.gif" width="24" height="11"></td>
</tr>
<tr>
<td width="16" height="16"><img src="/fr/images/roundtable/bot_lef.gif" width="16" height="16"></td>
<td height="16" background="/fr/images/roundtable/bot_mid.gif"><img src="/fr/images/roundtable/bot_mid.gif" width="16" height="16"></td>
<td width="24" height="16"><img src="/fr/images/roundtable/bot_rig.gif" width="24" height="16"></td>
</tr>
</table>
</div>
<!-- Fin de la table fancy round corner -->
<!--[if IE 8]>
<style type="text/css">
.tb{
float:left;
align:left;
width:550px;
scrolling-horizontal:none;
}
</style>
<![endif]-->
<!--[if IE 7]>
<style type="text/css">
.tb{
float:left;
align:left;
width:550px;
scrolling-horizontal:none;
}
</style>
<![endif]-->
<!--[if IE 6]>
<style type="text/css">
.tb{
float:left;
align:left;
width:550px;
scrolling-horizontal:none;
}
</style>
<![endif]-->
<br /><br />
<?php
}
}
?>
<?php
// close la connection
mysql_close($connection);
?>
Targets should be named frames or windows; older browsers do not use a frame's ID. So change:
<iframe id="frame" ...
To
<iframe name="frame" id="frame" ...

Categories