PHP Classes

File: ex3.php

Recommend this page to a friend!
  Classes of Marcos Bezerra   Web Open Patch   ex3.php   Download  
File: ex3.php
Role: Example script
Content type: text/plain
Description: Example #3: Anti-SQL Injection and Mail Injection Combined
Class: Web Open Patch
Filter values to prevent security exploits
Author: By
Last change:
Date: 14 years ago
Size: 544 bytes
 

Contents

Class file image Download
<?php

include_once("WebOpenPatch.php");

$wop = new WebOpenPatch();

$subject = $wop->wopAntiSqlInjection($_POST['subject']);
$to = 'faleconosco@dominio.com.br';
$msg = $wop->wopAntiSqlInjection($_POST['msg']);

if (
$wop->wopAntiMailInjection($_POST['from'])) {
   
$from = $_POST['from'];
} else {
    die(
"Email do remetente inválido!");
}

if (
mail($to, $subject, $msg, "From: {$from}\n")){
    echo
"Sua mensagem foi encaminhada com sucesso para {$to}.";
} else {
    echo
"Falha ao enviar a mensagem.";
}


?>