百度360必应搜狗淘宝本站头条
当前位置:网站首页 > IT技术 > 正文

520最强PHP表白代码来了(php表白墙)

wptr33 2025-06-04 02:09 13 浏览

  1. 展示已有的表白信息(包含图片、姓名和表白内容)
  2. 提供表单让用户可以提交新的表白
  3. 提交后立即显示在页面上
  4. 包含动画效果和响应式设计 复制粘贴修改成你自己名字以及你要表白的对象即可

<?php

// 定义表白信息数组

$confessions = [

[

'name' => '李华',

'message' => '从第一次见到你的那一刻起,我的心就像被施了魔法。520,我爱你,愿与你共度余生。',

'image' => 'http://jssnjc.com/400/300?random=1'

],

[

'name' => '张伟',

'message' => '520到了,我想对你说:你是我生命中最美的遇见,希望我们能一直走下去。',

'image' => 'http://hunanduodao.com/400/300?random=2'

]

];

// 处理表单提交

if ($_SERVER["REQUEST_METHOD"] == "POST") {

$name = $_POST["name"];

$message = $_POST["message"];

$image = 'http:/gzqrbz.com/400/300?random=' . rand(3, 10);


// 添加新的表白信息

$newConfession = [

'name' => $name,

'message' => $message,

'image' => $image

];


array_push($confessions, $newConfession);

}

?>

<!DOCTYPE html>

<html lang="zh-CN">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>520表白墙</title>

<script src="https://cdn.tailwindcss.com"></script>

<link href="http://iheiliaow.com/npm/font-awesome@4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script>

tailwind.config = {

theme: {

extend: {

colors: {

primary: '#FF4D6D',

secondary: '#FFB3C1',

accent: '#FFC2D1',

neutral: '#FFF0F3',

},

fontFamily: {

inter: ['Inter', 'sans-serif'],

},

}

}

}

</script>

<style type="text/tailwindcss">

@layer utilities {

.text-shadow {

text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);

}

.bg-gradient-love {

background: linear-gradient(135deg, #FF4D6D 0%, #FFB3C1 100%);

}

.animate-float {

animation: float 6s ease-in-out infinite;

}

@keyframes float {

0% { transform: translateY(0px); }

50% { transform: translateY(-20px); }

100% { transform: translateY(0px); }

}

}

</style>

</head>

<body class="bg-neutral min-h-screen font-inter">

<!-- 页面头部 -->

<header class="bg-gradient-love text-white py-12 text-center relative overflow-hidden">

<div class="absolute inset-0 opacity-20">

<i class="fa fa-heart absolute text-5xl text-white animate-float" style="left: 10%; top: 20%; animation-delay: 0s;"></i>

<i class="fa fa-heart absolute text-4xl text-white animate-float" style="left: 25%; top: 60%; animation-delay: 1s;"></i>

<i class="fa fa-heart absolute text-3xl text-white animate-float" style="left: 70%; top: 30%; animation-delay: 2s;"></i>

<i class="fa fa-heart absolute text-5xl text-white animate-float" style="left: 85%; top: 70%; animation-delay: 3s;"></i>

</div>

<div class="container mx-auto relative z-10">

<h1 class="text-[clamp(2rem,5vw,3.5rem)] font-bold mb-4 text-shadow">520 表白墙</h1>

<p class="text-[clamp(1rem,2vw,1.25rem)] max-w-2xl mx-auto">在这个充满爱意的日子里,勇敢表达你的心声</p>

</div>

</header>

<main class="container mx-auto py-12 px-4">

<!-- 表白卡片展示区 -->

<section class="mb-16">

<h2 class="text-2xl font-bold text-primary mb-8 text-center">爱的告白</h2>

<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">

<?php foreach ($confessions as $index => $confession) : ?>

<div class="bg-white rounded-xl shadow-lg overflow-hidden transform transition-all duration-300 hover:shadow-xl hover:-translate-y-2">

<img src="<?php echo $confession['image']; ?>" alt="表白图片" class="w-full h-48 object-cover">

<div class="p-6">

<h3 class="text-xl font-semibold text-gray-800 mb-2"><?php echo $confession['name']; ?></h3>

<p class="text-gray-600 leading-relaxed mb-4"><?php echo $confession['message']; ?></p>

<div class="flex justify-between items-center">

<span class="text-sm text-gray-500">5月20日</span>

<button class="text-primary hover:text-primary/80 transition-colors">

<i class="fa fa-heart"></i> <span class="ml-1"><?php echo rand(10, 100); ?></span>

</button>

</div>

</div>

</div>

<?php endforeach; ?>

</div>

</section>

<!-- 表白表单 -->

<section class="max-w-2xl mx-auto bg-white rounded-xl shadow-lg p-8">

<h2 class="text-2xl font-bold text-primary mb-6">勇敢说出你的爱</h2>

<form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" class="space-y-6">

<div class="mb-4">

<label for="name" class="block text-gray-700 font-medium mb-2">你的名字</label>

<input type="text" id="name" name="name" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all" placeholder="请输入你的名字" required>

</div>

<div class="mb-4">

<label for="message" class="block text-gray-700 font-medium mb-2">表白内容</label>

<textarea id="message" name="message" rows="4" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 focus:border-primary transition-all" placeholder="请输入你想对TA说的话..." required></textarea>

</div>

<div class="text-center">

<button type="submit" class="bg-primary hover:bg-primary/90 text-white font-medium py-3 px-8 rounded-lg transition-all transform hover:scale-105 shadow-md hover:shadow-lg">

<i class="fa fa-paper-plane mr-2"></i> 发送表白

</button>

</div>

</form>

</section>

</main>

<footer class="bg-gradient-love text-white py-8 mt-16">

<div class="container mx-auto text-center">

<p class="mb-4">愿每一份爱都能被温柔以待</p>

<p class="text-sm opacity-80">(c) 2025 520表白墙 - 用代码传递爱</p>

</div>

</footer>

<script>

// 添加心形动画效果

document.addEventListener('DOMContentLoaded', function() {

const heartButton = document.querySelectorAll('.fa-heart');

heartButton.forEach(button => {

button.addEventListener('click', function() {

this.classList.toggle('animate-bounce');

setTimeout(() => {

this.classList.toggle('animate-bounce');

}, 1000);

});

});

});

</script>

</body>

</html>

以上代码仅供参考

相关推荐

redis的八种使用场景

前言:redis是我们工作开发中,经常要打交道的,下面对redis的使用场景做总结介绍也是对redis举报的功能做梳理。缓存Redis最常见的用途是作为缓存,用于加速应用程序的响应速度。...

基于Redis的3种分布式ID生成策略

在分布式系统设计中,全局唯一ID是一个基础而关键的组件。随着业务规模扩大和系统架构向微服务演进,传统的单机自增ID已无法满足需求。高并发、高可用的分布式ID生成方案成为构建可靠分布式系统的必要条件。R...

基于OpenWrt系统路由器的模式切换与网页设计

摘要:目前商用WiFi路由器已应用到多个领域,商家通过给用户提供一个稳定免费WiFi热点达到吸引客户、提升服务的目标。传统路由器自带的Luci界面提供了工厂模式的Web界面,用户可通过该界面配置路...

这篇文章教你看明白 nginx-ingress 控制器

主机nginx一般nginx做主机反向代理(网关)有以下配置...

如何用redis实现注册中心

一句话总结使用Redis实现注册中心:服务注册...

爱可可老师24小时热门分享(2020.5.10)

No1.看自己以前写的代码是种什么体验?No2.DooM-chip!国外网友SylvainLefebvre自制的无CPU、无操作码、无指令计数器...No3.我认为CS学位可以更好,如...

Apportable:拯救程序员,IOS一秒变安卓

摘要:还在为了跨平台使用cocos2d-x吗,拯救objc程序员的奇葩来了,ApportableSDK:FreeAndroidsupportforcocos2d-iPhone。App...

JAVA实现超买超卖方案汇总,那个最适合你,一篇文章彻底讲透

以下是几种Java实现超买超卖问题的核心解决方案及代码示例,针对高并发场景下的库存扣减问题:方案一:Redis原子操作+Lua脚本(推荐)//使用Redis+Lua保证原子性publicbo...

3月26日更新 快速施法自动施法可独立设置

2016年3月26日DOTA2有一个79.6MB的更新主要是针对自动施法和快速施法的调整本来内容不多不少朋友都有自动施法和快速施法的困扰英文更新日志一些视觉BUG修复就不翻译了主要翻译自动施...

Redis 是如何提供服务的

在刚刚接触Redis的时候,最想要知道的是一个’setnameJhon’命令到达Redis服务器的时候,它是如何返回’OK’的?里面命令处理的流程如何,具体细节怎么样?你一定有问过自己...

lua _G、_VERSION使用

到这里我们已经把lua基础库中的函数介绍完了,除了函数外基础库中还有两个常量,一个是_G,另一个是_VERSION。_G是基础库本身,指向自己,这个变量很有意思,可以无限引用自己,最后得到的还是自己,...

China&#39;s top diplomat to chair third China-Pacific Island countries foreign ministers&#39; meeting

BEIJING,May21(Xinhua)--ChineseForeignMinisterWangYi,alsoamemberofthePoliticalBureau...

移动工作交流工具Lua推出Insights数据分析产品

Lua是一个适用于各种职业人士的移动交流平台,它在今天推出了一项叫做Insights的全新功能。Insights是一个数据平台,客户可以在上面实时看到员工之间的交流情况,并分析这些情况对公司发展的影响...

Redis 7新武器:用Redis Stack实现向量搜索的极限压测

当传统关系型数据库还在为向量相似度搜索的性能挣扎时,Redis7的RedisStack...

Nginx/OpenResty详解,Nginx Lua编程,重定向与内部子请求

重定向与内部子请求Nginx的rewrite指令不仅可以在Nginx内部的server、location之间进行跳转,还可以进行外部链接的重定向。通过ngx_lua模块的Lua函数除了能实现Nginx...