QQ:4869887 - Email:sos0716#163.com hewei's rss

何为 > 网站研究 > 正文

php菜鸟学习记录

国外的空间都是php,只能遵循老外的规则,我这个程序菜鸟也初步专研了一下php。学习笔记记录如下:

1、php参数传递和php转向

在asp里面,这样用

<%
dim canshu
canshu=request("canshu")
if canshu<>"" then
response.redirect ""&canshu&""
else
response.redirect "http://hewei.org"
end if
%>

链接是这样 http://hewei.org/zhuanxiang.asp?canshu=http://hewei.org

那么到php我们这样写(我研究了很久哦)

<?php
$canshu =$_GET['canshu'];
if ($canshu=="")
{
header("Location: http://hewei.org");
}
else
{
header("Location: $canshu");
}
?>

链接是这样 http://hewei.org/zhuanxiang.php?canshu=http://hewei.org

2、搞一个php提交表单再验证email对不对。

老外的网站经常搞一个email订阅的东西,我也搞一个,不过是个假的,欺骗一下老外,反正不会发邮件,但是这个表面功夫还是可以做一下。

首页搞一个提交的表单:

<form action="subscribe.php" method="post">
<input type="text" name="email" value="Enter e-mail address" onclick="this.value=''" />
<input type="image" src="/img/signup.gif" alt="subscribe" />
</form>

然后搞一个验证页面,如果email有问题,则提示email不对,如果email是好的,则提示他的email已经加入订阅列表。

<?php

$email=$_POST['email'];

if (eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}contentquot;,$email))
{
echo "<strong>Thank You for subscribing.</trong>";
echo "<p>You're almost done. Your E-mail is <strong>$email</strong>. We will keep you up-to-date on topics and offers that interest you!</p>";
}
else
{
echo "<strong>Please input a correct E-mail!</strong>";
}
?>

这样看起来也是那么回事了,至于收不收都得到那根我没关系了,反正也是忽悠一下。

  • 相关文章
网友评论»查看所有评论返回顶部
About Hewei.org

何为的博客。记录我的生活点滴,技术经验,奇思妙想。无聊的时候看看自己记录的思想,也是一种享受。

订阅何为的博客
  • ZhuaXia 订阅到抓虾
  • SouYo 订阅到沙发
信息检索 In Hewei.org
Hot标签
最新推荐主题
最新推荐专题
何为博客!意欲何为?大有作为!Copyright © HeWei.Org
皖ICP备06010916号