一个很简单的php留言板。筹建在sae上的。
一个很简单的php留言板。。。。搭建在sae上的。。。
我在sae上搭建了一个个人简历的页面: 有兴趣的可以访问 http://671coder.sinaapp.com/
在做下面一个简单的留言板的时候,卡了我很久,虽然完全没用过php。。但是还是最后勉强写出来了。。。
主页面html是这样写的:
<div class="row row-contact" id="contact_row" style="display: block"> <article> <h2 id="Contact-Me">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; $ierrno() != 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>
然后最后显示留言板是这么写的:
<meta charset="utf-8"> <title>My messages</title> <link href="%E2%80%9Dhttp://fonts.googleapis.com/css?family=Reenie+Beanie:regular%E2%80%9D" 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> <?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) { ?>
-
echo "
-
=$user?>:
=$text?>
671coder's message:
"; while ($r = mysql_fetch_array($result)) { $idx = $r["MId"]; $user = $r["MName"]; $text = $r["MText"]; ?>
怎么样!感觉上很炫吧!
数据库的话想必大家都知道是怎么设计的了吧?!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

How to use CSS to implement rotating background image animation effects of elements. Background image animation effects can increase the visual appeal and user experience of web pages. This article will introduce how to use CSS to achieve the rotating background animation effect of elements, and provide specific code examples. First, we need to prepare a background image, which can be any picture you like, such as a picture of the sun or an electric fan. Save the image and name it "bg.png". Next, create an HTML file and add a div element in the file, setting it to

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Interpretation of CSS3D view properties: transform and perspective, specific code examples are required Introduction: In modern web design, 3D effects have become a very popular element. Through the transform and perspective properties of CSS, we can easily add 3D visual effects to web pages to make them more vivid and attractive. This article will explain these two properties and provide specific code examples. 1. transform attribute: transf

How to compress and format images in Vue? In front-end development, we often encounter the need to compress and format images. Especially in mobile development, in order to improve page loading speed and save user traffic, it is critical to compress and format images. In the Vue framework, we can use some tool libraries to compress and format images. Compression using the compressor.js library compressor.js is a JavaS for compressing images

How to implement image animation and gradient effects in Vue? Vue is a progressive framework for building user interfaces that makes it easy to implement animations and gradient effects. In this article, we will introduce how to use Vue to implement image animation and gradient effects, and provide some code examples. 1. Use Vue’s transition effects to implement image animation. Vue provides built-in instructions for transition effects, making it easy to add animation effects to HTML elements. When using transition effects, you can wrap picture elements and add transition instructions on the elements. Example
