dovrei mettere in tutte le aree di testo dei caratteri minimi e massimi, poi ho anche un problema quando un utente compila tutti i campi e invia un email al mio indirizzo email si disconnette dal mi sito, non so qual è il problema potete risolverlo voi? grazie mille raga
html
Codice PHP:
<form action="http://amoreamiciza.altervista.org/php/contactking.php" method="post" id="form_login">
<h1>Dati account world live</h1>
<div>
<span style="color:#F00"><?php echo $_SESSION['nameerror'] ?></span>
<input name="name" class="utente" id="name" placeholder="inserisci il tuo nome utente di world live" value="<?php echo $_SESSION['name'] ?>" maxlength="60"/>
</div>
<div>
<span style="color:#F00"><?php echo $_SESSION['emailerror'] ?></span>
<input name="email" class="email" id="email" value="<?php echo $_SESSION['email'] ?>" maxlength="100" placeholder="Inserisci la tua email di world live" />
</div>
<div>
<span style="color:#F00"><?php echo $_SESSION['subjecterror'] ?></span>
<input maxlength="49" name="subject" id="subject" placeholder="Inserisci l'url della domanda che vuoi scoprire" value="<?php echo $_SESSION['subject'] ?>" class="link"/>
</div>
<div>
<span style="color:#F00"><?php echo $_SESSION['messageerror'] ?></span>
<textarea name="message" cols="40" rows="4" id="message" maxlength="200" placeholder="scrivi i 10 nuovi utenti ad esempio: franci94, luca95, silvia ecc.. " class="textarea"><?php echo $_SESSION['message'] ?></textarea>
<p class="contactform"><strong>Anti Spam: *</strong><br />
Seleziona il campo su si
<select name="humancheck" id="humancheck">
<option value="---">---</option>
<option value="no">No</option>
<option value="yes">Si</option>
</select>
<span style="color:#F00"><?php echo $_SESSION['humanerror'] ?></span>
</div>
<div>
<input type="submit" name="button" id="button" value="Invia" />
<span style="color:#F00"><?php echo $_SESSION['senderror'] ?></span>
</div>
</form>
php
Codice PHP:
<?php
//Includes user settings
include('config.php');
session_start();
$name = $_POST['name'];
$email = $_POST['email'];
$tel = $_POST['tel'];
$human = $_POST['humancheck'];
$message = $_POST['message'];
$callback = $_POST['callback'];
$subject = $_POST['subject'];
$ip = $_SERVER['REMOTE_ADDR'];
$error = false;
//Reset error messages
$_SESSION['emailerror'] = "";
$_SESSION['nameerror'] = "";
$_SESSION['subjecterror'] = "";
$_SESSION['messageerror'] = "";
$_SESSION['humanerror'] = "";
$_SESSION['senderror'] = "";
//Validation Session Variables
$_SESSION['message'] = $message;
$_SESSION['tel'] = $tel;
$_SESSION['name'] = $name;
$_SESSION['email'] = $email;
$_SESSION['subject'] = $subject;
//Validation
if($name == ""){
$_SESSION['nameerror'] = "Inserisci il tuo nome utente";
$error = true;
}
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
$_SESSION['emailerror'] = "Please check your email is valid.";
$error = true;
}
if($email == ""){
$_SESSION['emailerror'] = "Inserisci il tuo indirizzo email";
$error = true;
}
if($subject == ""){
$_SESSION['subjecterror'] = "Inserisci l'url della domanda";
$error = true;
}
if($message == ""){
$_SESSION['messageerror'] = "Si prega di digitare un messaggio.";
$error = true;
}
if($human != "yes"){
$error = true;
$_SESSION['humanerror'] = "Please select yes.";
}
if($error == true) {
$_SESSION['senderror'] = "Compila tutti i campi";
header("Location: $contactpage");
exit;
} else {
$to = $youremail;
$sbj = "Codice di ask © 2013, Tutti i diritti riservati";
$msg = "
<html>
<head>
<style type='text/css'>
body{
font-family:'Lucida Grande', Arial;
color:#333;
font-size:15px;
}
</style>
</head>
<body>
<img src='"."$logo"."' width='255' height='124' alt='contact' />
<table width='600' border='0' cellspacing='0' cellpadding='5'>
<tr>
<td width='121' align='right' valign='baseline'><strong>Name:</strong></td>
<td width='459'>$name</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>Email:</strong></td>
<td>$email</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>IP:</strong></td>
<td>$ip</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>Subject:</strong></td>
<td>$subject</td>
</tr>
<tr>
<td align='right' valign='baseline'><strong>Message:</strong></td>
<td>$message</td>
</tr>
<tr>
<td> </td>
<td>Inviato alle " . date("d/m/Y H:i:s") . "</td>
</tr>
<tr>
<td> </td>
<td><small>Copyright © 2014. World Live ask.fm</small></td>
</tr>
</table>
</body>
</html>
";
$from = $email;
$headers = 'MIME-Version: 2.1' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: $from";
mail($to,$sbj,$msg,$headers); //Send to you.
//END OF EMAIL TO ME
//START EMAIL CONFIRMATION
$toClient = $email;
$msgClient = "
<html>
<head>
<style type='text/css'>
body{
font-family:'Lucida Grande', Arial;
color:#333;
font-size:15px;
}
</style>
</head>
<body>
<img src='"."$logo"."' width='255' height='124' alt='contact' />
<table width='600' border='0' cellspacing='0' cellpadding='5'>
<tr>
<td width='117' align='right' valign='baseline'><strong>Thank you,</strong></td>
<td width='463'>$name</td>
</tr>
<tr>
<td> </td>
<td>We have recieved your message and will get back to you as soon as possible.</td>
</tr>
<tr>
<td> </td>
<td><small>Powered by ContactKing | © Copyright 2010 creativeben.co.uk</small></td>
</tr>
</table>
</body>
</html>
";
$fromClient = $email;
$sbjClient = "Thank you, $name - $yourwebsite";
$headersClient = 'MIME-Version: 1.0' . "\r\n";
$headersClient .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headersClient .= "From: $fromClient";
mail($toClient,$sbjClient,$msgClient,$headersClient); //Send to Client.
//END EMAIL CONFIRMATION
//Reset error messages
$_SESSION['emailerror'] = "";
$_SESSION['nameerror'] = "";
$_SESSION['subjecterror'] = "";
$_SESSION['messageerror'] = "";
$_SESSION['humanerror'] = "";
$_SESSION['senderror'] = "";
//Reset Validation Session Variables
$_SESSION['message'] = "";
$_SESSION['tel'] = "";
$_SESSION['name'] = "";
$_SESSION['email'] = "";
$_SESSION['subject'] = "";
session_destroy();
header("Location: $thankyoupage");
exit;
}
?>