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>";
}
?>
这样看起来也是那么回事了,至于收不收都得到那根我没关系了,反正也是忽悠一下。
- 相关文章
- 上一篇:ASP0104:80004005错误
- 下一篇:深入研究动易的生成rss









