Please help
i have a support section (Support.php) that the content of it is from ShowSupportForm.inc, the action of ShowSupportForm.inc is SendMail.php which the content is from SendMail.inc
now i have 2 problems:
first, by using sessions, after refreshing i wanna show old values in my support form but i cant 😕
second, in SendMail.inc i check the necessary fields fill or not, but i dont know how to chek email format there too?!
Support.php:
<?php
session_start();
include("../php/pagepart/ShowSupportForm.inc");
$errorMessage="";
if(@isset($_GET['errorMessage'])){
if($_GET['errorMessage']=="FillFormError")
$errorMessage="fill the necessary fileds.";
}
?>
<html>
<body>
<table>
<tr>
<td align="center"><p align="center" dir="rtl" ><font color="red"><? echo $errorMessage; ?></font></p></td>
</tr>
<tr>
<td><? ShowSupportForm::show(); ?></td>
</tr>
</table>
</body>
</html>
ShowSupportForm.inc:
<?
class ShowSupportForm{
function show(){
echo "<form id=\"Frm\" name=\"Frm\" method=\"post\" action=\"..\pages\SendMail.php\">\n" .
"<table width=\"\" cellspacing='0' border='0'>\n" .
"<tr>\n" .
"<td align=\"right\" valign=\"bottom\">fname: </td><td><input name=\"fname\" type=\"text\" id=\"fname\" maxlength=\"100\" /> *</td></tr>\n" .
"<tr>\n" .
"<td align=\"right\" valign=\"bottom\">lastname : </td><td><input name=\"lname\" type=\"text\" id=\"lname\" maxlength=\"100\" /> *</td></tr>\n" .
"<tr>\n" .
"<td align=\"right\" valign=\"bottom\">email: </td><td><input name=\"email\" type=\"text\" id=\"email\" maxlength=\"100\" /> *</td></tr>\n" .
"<tr>\n" .
"<td align=\"right\" valign=\"bottom\">tel: </td><td><input name=\"tel\" type=\"text\" id=\"tel\" maxlength=\"100\" /></td></tr>\n" .
"<tr>\n" .
"<td align=\"right\" valign=\"bottom\">comment : </td><td><textarea name=\"comment\" id=\"comment\" cols=\"50\" rows=\"7\" ></textarea> *</td></tr>\n" .
"<tr>\n" .
"<td colspan='2' align='center'><input name='submit' type='submit' value='send'> <input name='reset' type='reset' value='clear'></td>\n" .
"</tr></table></form>";
}
}
?>
SendMail.php:
<?php
ob_start();
include("../php/bean/SendMail.inc");
?>
<html>
<body>
<table>
<tr>
<td><p align="center"><? SendMail::sendMail(); ?></p></td>
</tr>
</table>
</body>
</html>
SendMail.inc:
<?php
class SendMail{
function sendMail(){
ob_start();
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$tel = $_POST['tel'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$_SESSION['fname'] = $fname;
$_SESSION['lname'] = $lname;
$_SESSION['tel'] = $tel;
$_SESSION['email'] = $email;
$_SESSION['comment'] = $comment;
if(strlen($fname)<1){
header("location: ../pages/Support.php?errorMessage=FillFormError");
return false;
}
if(strlen($lname)<1){
header("location: ../pages/Support.php?errorMessage=FillFormError");
return false;
}
if(strlen($email)<1){
header("location: ../pages/Support.php?errorMessage=FillFormError");
return false;
}
/*if(!eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $email)) {
how to check 2 condition at the same time?
}*/
if(strlen($comment)<1){
header("location: ../pages/Support.php?errorMessage=FillFormError");
return false;
}
if(strlen($tel)<1){
$tel = "-";
}
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "host";
$mail->SMTPAuth = true;
$mail->Username = "username";
$mail->Password = "pass";
$mail->From = "from";
$mail->FromName = $fname." ".$lname;
//$mail->FromName = "from name";
$mail->AddAddress("address");
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = " subject";
$mail->Body = "<html><body><h4 align='right' dir='rtl' color='gray'>detail is: :</h4>\n
<table align=right bgcolor=''>
<tr><td align=right dir='rtl'><p align=right dir='ltr'>".$fname ."</p></td><td><p align=right dir='ltr'><strong>: fname</strong></td></tr>
<tr><td align=right dir='rtl'><p align=right dir='ltr'>".$lname ."</p></td><td><p align=right dir='ltr'><strong>: lastname </strong></td></tr>
<tr><td align=right dir='rtl'><p align=right dir='ltr'>".$tel ."</p></td><td><p align=right dir='ltr'><strong>: tel</strong></td></tr>
<tr><td align=right dir='rtl'><p align=right dir='ltr'>".$email ."</p></td><td><p align=right dir='ltr'><strong>: email</strong></td></tr>
<tr><td align=right dir='rtl'><p align=right dir='ltr'>".nl2br($comment)."</p></td><td><p align=right dir='ltr'><strong>: comment </strong></td></tr>
</table></body>\n</html>\n";
if(!$mail->Send())
{
$isTrue = false;
$error = "not send".$mail->ErrorInfo;
echo $error;
return false;
}else{
$error = "sent";
echo $error;
return true;
}
ob_end_flush();
}
}
}
?>
thanks in advance