![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
[PHP]
<?php
// Beginning php
// Saving the page header in the variable $head.
$head = <<Feedback form
ENDH;
// End of page header
// Saving the page footer in the variable $tail.
$tail = <<
Name: <?php echo $name ?>
Email: <?php echo $email ?>
Feedback: <?php echo $feedback ?>
<?php
// Mails the feedback to the webmaster.
$subject = "Feedback from your site";
$sendto = "webamster@example.com";
$header = "From: $email";
mail($sendto, $subject, $feedback, $header);
print "Thank you. Your comments have been sent to the webmaster\n";
// Print end and leave
print $tail;
exit();
}
// This loop treats users who have not been to the site before.
if(!$$n_last) {
if( ! isset($name)) { // if no name - display the form
echo $head;
?>
Welcome to our system! Please fill in the following information:
<?php
echo $tail;
exit;
} else {
// Set cookies and continue
Setcookie($n_name,$name,time()+$cookie_life);
Setcookie($n_email,$email,time()+$cookie_life);
$$n_name = $name;
$$n_email = $email;
}
}
// This loop treats repeat users.
Setcookie($n_last,Date("H:i d/m/Y"),time()+$cookie_life);
echo $head;
?>
Welcome back to our system, <?php echo $$n_name ?>.
<?php
// Have previous login
if($$n_last)
echo "Your last login was on " . $$n_last . ".";
// User fills in feedback form
?>
<?php echo $tail ?>[/PHP]

