我在sae上搭建了一个个人简历的页面: 有兴趣的可以访问  http://671coder.sinaapp.com/

在做下面一个简单的留言板的时候,卡了我很久,虽然完全没用过php。。但是还是最后勉强写出来了。。。

主页面html是这样写的:

    <div class="row row-contact" id="contact_row" style="display: block">
<article> <h2 class="section-title">Contact Me</h2> <p>This block can be hidden and only shown in <a class="zoom-html">a popup</a>.</p> <div class="wrap-contact-form">
<form id="contacts" class="contact-form" action="/db/submitform.php" method="post">
<table class="info">
<tr>
<th><label for="contact_name">Name</label></th>
<td><input type="text" class="input-text" name="contact_name" id="contact_name" value="" maxlength="10"></td>
</tr>
<!-- start spam protection
<tr class="spam-protection">
<th><label>E-mail</label></th>
<td><input type="text" name="email" value=""></td>
</tr>
end -->
<tr>
<th><label for="contact_code">Security code</label></th>
<td><input type="text" class="input-text" name="contact_code" id="contact_code" maxlength="4"></td>
</tr> <tr>
<th><label for="contact_message">Your Message</label></th>
<td><textarea id="contact_message" name="contact_message" maxlength="200"></textarea></td>
</tr>
<tr>
<th></th>
<td>
<input type="submit" class="input-submit" name="contact_send" value="Send">
<div class="on-success">
Thank You. The message was sent.
</div>
<!--
<div class="on-error">
A technical error occured. Message was not delivered. Please contact me over e-mail.
</div>
-->
</td>
</tr>
</table>
</form>
</div> </article>
</div>

验证码功能暂时还没有实现。。。

后台的php是这样写的:

<?php

	$name = $_POST['contact_name'];
$message = $_POST['contact_message']; if (strlen($name) == 0 || strlen($message) == 0) {
?><script>
alert("Sorry, your name and your message can not be empty.");
window.history.back(-1);
</script><?
} $m_notchar="$#@!%&*?<>"; $mysql = new SaeMysql(); $judge = true;
for ($i=0; $i<10; $i++) {
if (strpos($name, substr($m_notchar, $i, 1)) || strpos($message, substr($m_notchar, $i, 1)))
$judge = false;
}
if( $mysql->errno() != 0 ) {
die( "Error:" . $mysql->errmsg() );
} else if (!$judge) {
?><script>alert("Sorry, your message has illegal characters, please re-enter checked.");</script><?
} else {
$sql = "INSERT INTO Message (MName, MText) VALUES ('$name', '$message')";
$mysql->runSql( $sql );
?><script>alert("Thank you for your message!");</script><?
}
$mysql->closeDb(); ?>
<script>window.history.back(-1);</script>

然后最后显示留言板是这么写的:

<html>
<head>
<meta charset="utf-8">
<title>My messages</title> <link href=”http://fonts.googleapis.com/css?family=Reenie+Beanie:regular” rel=”stylesheet” type=”text/css”>
<style type="text/css">
*{
margin:0;
padding:0;
}
body{
font-family: arial,sans-serif;
font-size:100%;
margin:3em;
background:#666;
color:#fff;
}
h2,p{
font-size:100%;
font-weight:normal;
}
ul,li{
list-style:none;
}
ul{
overflow: hidden;
padding:3em;
}
ul li a{
text-decoration:none;
color:#000;
background:#ffc;
display:block;
height:10em;
width:10em;
padding:1em;
-moz-box-shadow:5px 5px 7px rgba(33,33,33,1);
-webkit-box-shadow: 5px 5px 7px rgba(33,33,33,.7);
box-shadow: 5px 5px 7px rgba(33,33,33,.7);
/*倾斜正方形*/
-webit-transform: rotate(-6deg);
-o-transform: rotate(-6deg);
-moz-transform: rotate(-6deg);
/*添加鼠标放上时的平滑过渡*/
-moz-transition:-moz-transform .15s linear;
-o-transition:-o-transform .15s linear;
-webkit-transition:-webkit-transform .15s linear; }
ul li{
margin:1em;
float:left;
}
ul li h2{
font-size:140%;
font-weight:bold;
padding-bottom:10px;
}
ul li p{
font-family:"Reenie Beanie",arial,sans-serif,微软雅黑;
font-size:110%;
}
ul li:nth-child(even) a{
-o-transform: rotate(4deg);
-webkit-transform: rotate(4deg);
-moz-transform: rotate(4deg);
position:relative;
top:5px;
background:#cfc ;
} ul li:nth-child(3n) a{
-o-transform: rotate(-3deg);
-webkit-transform: rotate(-3deg);
-moz-transform: rotate(-3deg);
position:relative;
top:-5px;
background:#ccf ;
}
ul li:nth-child(5n) a{
-o-transform: rotate(5deg);
-webkit-transform: rotate(5deg);
-moz-transform: rotate(5deg);
position:relative;
top:-10px;
}
ul li a:hover, ul li a:focus{
-moz-box-shadow:10px 10px 7px rgba(0,0,0,.7);
-webkit-box-shadow:10px 10px 7px rgba(0,0,0,.7);
-box-shadow:10px 10px 7px rgba(0,0,0,.7);
-webkit-transform:scale(1.25);
-moz-transform:scale(1.25);
-o-transform:scale(1.25);
position:relative;
z-index:5;
}
</style>
</head> <body> <?php
$link=mysql_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
if(!$link)die('could not connect'.mysql_error()); mysql_select_db(SAE_MYSQL_DB,$link); $query = "select * from app_671coder.Message";
$result = mysql_query( $query );
if ($result) {
?>
<ul>
<?
echo "<p><font size=7>671coder's message:</font></p><br><p></p>"; while ($r = mysql_fetch_array($result)) {
$idx = $r["MId"];
$user = $r["MName"];
$text = $r["MText"];
?>
<li>
<a href ="#">
<h2><?=$user?>:</h2>
<p><?=$text?></p>
</a>
</li>
<?php
}
?>
</ul>
<?
} else {
echo "No data.";
}
//mysql_free_result($result);
//$mysql->closeDb();
?>
</body> </html>

怎么样!感觉上很炫吧!

数据库的话想必大家都知道是怎么设计的了吧?!

一个很简单的php留言板。。。。搭建在sae上的。。。的更多相关文章

  1. 一个超级简单php的留言板

    第一步:配置好测试环境:(详细略了) 第二部:新建一个数据库,命名为guestbook(名字可以随便改),可以直接在phpmyadmin里面操作,在数据库里面新建一张表‘content’,表里面有4个 ...

  2. 写一个简单的HTML留言板

    最近有点懒,没码什么字,防止遗忘,从头开始码,写一个简单的HTML留言板.包含两个文件,book.html还有style.css,放在同一目录下. book.html 1 <!DOCTYPE h ...

  3. [.NET] 打造一个很简单的文档转换器 - 使用组件 Spire.Office

    打造一个很简单的文档转换器 - 使用组件 Spire.Office [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/6024827.html 序 之前,& ...

  4. 问题:关于一个贴友的js留言板的实现

    需求:用js做一个简单的留言板效果 html部分: 1: <!DOCTYPE> 2: <html lang="zh-en"> 3: <head> ...

  5. java(itext) 一个很简单的PDF表格生成工具

    先上个效果图 因为做的项目涉及到数据预测,其中有大量打印业务来支撑实体店的运营,因为注重的是数据,要求简洁,清晰,所以写了个很简单也很实用的工具类. 如果需要编写样式或者插入背景,都可以查阅itex官 ...

  6. 一个很简单的jQuery插件实例教程(菜鸟级)

    很多公司的前端设计开发人员都是女孩子,而这些女孩子很多JavaScript技能都不是很好.而前端开发过程中,JavaScript技能又是必不可少的.所以,如果前端小MM正在为某个JavaScript效 ...

  7. 个人网页的留言板实现与sae的数据库账户配置

    个人网页(github)的留言板终于搞定了.总之后端的东西不会写,只有修改以前教程里面的文件.记录一下重要的过程. 使用了留言保存的send()函数,模版有注册登录功能.根据需求修改了一下,去掉了登录 ...

  8. 一个很简单的SqlServer生成常用C#语句工具的诞生

    前言: 这个文章只要是记录一下,这个工具的诞生过程.作用.其中的技术实在是太简单可以说没有什么技术~主要是锻炼一下写文章的能力! 正文: 在开发项目的时,常常会要维护或变更一些老项目,涉及到简单的几张 ...

  9. 『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]-CodeForces 236A,虽然很水,但有一个很简单的函数用起来方便

    A. Boy or Girl time limit per test 1 second memory limit per test 256 megabytes input standard input ...

随机推荐

  1. Python模拟登陆

    模拟人人登陆 #encoding=utf-8 import urllib2 import urllib import cookielib def renrenBrower(url,user,passw ...

  2. nodejs笔记2——请求路由

    对于不同的URL请求,服务器应该有不同的反应.我们要为路由提供请求的URL和其他需要的GET及POST参数,随后路由需要根据这些数据来执行相应的代码.我们需要的所有数据都会包含在request对象中, ...

  3. Android模拟器启动异常

    设置系统环境变量的 ANDROID_SDK_HOME为任意一个目录,我的目录:C:\android_avd, 关闭eclipse,然后重新启动eclipse, 删除之前创建的AVD, 然后重新创建,即 ...

  4. 我的Python成长之路---第三天---Python基础(10)---2016年1月16日(雾霾)

    二.collections collections是对Python现有的数据类型的补充,在使用collections中的对象要先导入import collections模块 1.Counter——计数 ...

  5. C语言深度剖析---const关键字(转载)

    const是constant的缩写,是恒定不变的意思.被const修饰的值,是只读变量. 1.const修饰只读变量,具有不变性      #include <stdio.h> int m ...

  6. 面向对象程序设计-C++ Steam & Vector 【第三次上课笔记】

    大家可以下载后用Vim 或者 Sublime Text等文本编辑器查看 Conference: http://blog.csdn.net/candy1232009/article/details/70 ...

  7. MVC-01 概述

    一.何谓MVC 1.MVC是开发时所使用的一种架构(框架). 2.目的在于简化软件开发的复杂度,以一种概念简单却又权责分明的架构,贯穿整个软件开发流程,通过“商业逻辑层”与“数据表现层”的切割,让这两 ...

  8. aliyun 主机Nginx 上配置Drupal 伪静态

    网上找了好久没有正确的,后面直接在http://wiki.nginx.org/Drupal 上找到原文.但原文中复制过来会出现个 'root' rewrite directive is duplica ...

  9. .NET截断字符串

    /// <summary> /// 截断字符串 /// </summary> /// <param name="s">要截断的字符串</p ...

  10. windows phone7开发环境配置错误

    遇到下面这样一个问题:在配置windows phoe7开发环境的时候出现如下错误,以及相应的解决方案,希望对大家有所帮助. 装完环境后出现下面错误: [caption id="attachm ...