麻辣堂|资源主站|开发论坛|在线手册
首页 Apache Linux Java MySQL 注册帮助 
PHP项目开发组是PHP开发资源网于2007组年建成立的项目开发团队,目前核心开发成员有27人, 项目协作成员8名.下设7个开发组,主要承接大/中型网站项目开发任务。

    由于开发任务较多,人员比较紧张,现面向社会招聘全职或者兼职开发人员,不管你是在校大学生,还是全职开发人员,以及SOHO都可以联系本站,我们可以长期合作,并为您带来丰厚的报酬。
  您现在的位置:PHP开发资源网 > 麻辣堂 > 详细资料
待解决
表单,cookie处理代码
悬赏分:20 - 2007年05月29日

[PHP] <?php // Beginning php // Saving the page header in the variable $head. $head = << Feedback form

Feedback form

ENDH; // End of page header // Saving the page footer in the variable $tail. $tail = << ENDT; // End of page footer // Set up variables that will be saved in the cookies // Define unique cookie prefix $ID = "My_ID"; // Cookie lifetime in seconds (in this example, three days) $cookie_life = 3*24*3600; // Name of cookie that holds the user's name $n_name = $ID . "_Name"; // Name of cookie that holds the user's email $n_email = $ID . "_Email"; // Name of cookie that holds the user's last login $n_last = $ID . "_Last"; // These lines print the form with user input and mails to the webmaster. if( isset($sfeedback)) { Setcookie($n_last,Date("H:i d/m/Y"),time()+$cookie_life); print $head; ?> Thanks for your feedback, <?php echo $name ?>. Here is what you said:
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:
Name:
Email:
<?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 ?>
Name:
Email:
Feedback:

<?php echo $tail ?>[/PHP]

提问者:cherishlyc   05-29 14:02
答复
路过。。。顺便帮顶:)
回答者:玉米づ冰冻可乐 - 瓦岗村民 8-22 09:10
我也来回答:
不管你有没有帮助我们,瓦岗寨8万村民将感谢你。。。。。

为防止灌水,您需要计算一道数学题: 答案:
36 + 9 = ? 请将计算结果填在上面

 
[]
©2007 PhpRes.COM