Hello
I have two great scripts together, and separately they work perfect, but when i tried to combine them i failed.
first one just Displays the same header for each page and adds a content for each page individually.
second scipt processes feedback from the site page - like a person fills in teh box and clicks a button and text is sent to the email address which was defined in the script,
and if smth's wrong , the words like "that is not a valid email address" show up.
when it's right, a visitor sees smth like "your email has been sent to.... Thanks"
i wanted to combine them so when a visitor sees the answer after he sent feedback, the same header will be at the top of a page like at all site pages.
Can you help me plz?
- feedback.php
<?
$name=trim($name);
$email=trim($email);
$feedback=trim($feedback);
if (!ereg("[a-zA-Z0-9_]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$", $email))
{
echo "That is not a valid email address. Please return to the"
." previous page and try again.";
exit;
}
$toaddress = "feedback@bobsdomain.com"; // the default value
// Change the $toaddress if the criteria are met
// String version
/*
if (strstr($feedback, "shop"))
$toaddress = "retail@bobsdomain.com";
else if (strstr($feedback, "delivery"))
$toaddress = "fulfilment@bobsdomain.com";
else if (strstr($feedback, "bill"))
$toaddress = "accounts@bobsdomain.com";
$email_array = explode("@", $email);
if ($email_array[1]=="bigcustomer.com")
$toaddress = "bob@bobsdomain.com";
*/
// regular expression version
if (ereg("shop|customer service|retail", $feedback))
$toaddress = "retail@bobsdomain.com";
else if (ereg("deliver.|fulfil.", $feedback))
$toaddress = "fulfilment@bobsdomain.com";
else if (ereg("bill|account", $feedback))
$toaddress = "accounts@bobsdomain.com";
if (eregi("bigcustomer.com", $email))
$toaddress = "bob@bobsdomain.com";
$subject = "Feedback from web site";
$mailcontent = "Customer name: ".$name."\n"
."Customer email: ".$email."\n"
."Customer comments: \n".$feedback."\n";
$fromaddress = "webserver@bobsdomain.com";
mail($toaddress, $subject, $mailcontent, $fromaddress);
?>
<html>
<head>
<title>Bob's Auto Parts - Feedback Submitted</title>
</head>
<body>
<h1>Feedback submitted</h1>
<p>Your feedback (shown below) has been sent to <? echo $toaddress; ?></p>
<p><? echo nl2br($mailcontent); ?> </p>
</body>
</html>
- contactus.php
<?
require ("page.inc");
class ContactPage extends Page
{ function Display()
{
echo "<html>\n<head>\n";
$this -> DisplayTitle();
$this -> DisplayKeywords();
$this -> DisplayContentdescription();
$this -> DisplayStyles();
echo "</head>\n<body cellspacing=0 cellpadding=0 leftmargin=0 rightmargin=0 topmargin=0 marginheight=0 marginwidth=0>\n";
$this -> DisplayHeader();
$this -> DisplayMenu($this->buttons);
echo $this->content;
$this -> DisplayFooter();
echo "</body>\n</html>\n";
}
}
$contact = new ContactPage();
$content = "<table background color=#ffffff border=0 cellspacing=20 cellpadding=20>
<tr><td>
<p class=\"header\">Contact Us!
</p><br>
<p>We'll be glad to answer any questions you have:</p>
<form method=post action=\"processfeedback.php\">
Your name: <br>
<input type=text name=\"name\" size=40><br>
Your email address: <br>
<input type=text name=\"email\" size=40><br>
Your feedback:<br>
<textarea name=\"feedback\" rows=5 cols=30>
</textarea><br>
<input type=submit value=\"Send feedback\" class=\"header\">
</form>
</body>
</td></tr></table>";
$contact ->SetContent($content);
$contact ->Display();
?>
thank you!