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

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

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

  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>

以上代码仅供参考

相关推荐

Linux文件系统操作常用命令(linux文件内容操作命令)

在Linux系统中,有一些常用的文件系统操作命令,以下是这些命令的介绍和作用:#切换目录,其中./代表当前目录,../代表上一级目录cd#查看当前目录里的文件和文件夹ls#...

别小看tail 命令,它难倒了技术总监

我把自己以往的文章汇总成为了Github,欢迎各位大佬star...

lnav:基于 Linux 的高级控制台日志文件查看器

lnav是一款开源的控制台日志文件查看器,专为Linux和Unix-like系统设计。它通过自动检测日志文件的格式,提取时间戳、日志级别等关键信息,并将多个日志文件的内容按时间顺序合并显示,...

声明式与命令式代码(声明模式和命令模式)

编程范式中的术语和差异信不信由你,你可能已经以开发人员的身份使用了多种编程范例。因为没有什么比用编程理论招待朋友更有趣的了,所以这篇文章可以帮助您认识代码中的流行范例。命令式编程命令式编程是我们从As...

linux中的常用命令(linux常用命令和作用)

linux中的常用命令linux中的命令统称shell命令shell是一个命令行解释器,将用户命令解析为操作系统所能理解的指令,实现用户与操作系统的交互shell终端:我们平时输入命令,执行程序的那个...

提高工作效率的--Linux常用命令,能够决解95%以上的问题

点击上方关注,第一时间接受干货转发,点赞,收藏,不如一次关注评论区第一条注意查看回复:Linux命令获取linux常用命令大全pdf+Linux命令行大全pdf...

如何限制他人操作自己的电脑?(如何控制别人的电脑不让发现)

这段时间,小猪罗志祥正处于风口浪尖,具体是为啥?还不知道的小伙伴赶紧去补一下最近的娱乐圈八卦~简单来说,就是我们的小罗同事,以自己超强的体力,以及超强的时间管理能力,重新定义了「多人运动」的含义,重新...

最通俗易懂的命令模式讲解(命令模式百科)

我们先不讲什么是命令模式,先通过一个场景来引出命令模式,看看命令模式能解决什么样的问题。现在有一个渣男张三,他有还几个女朋友,你现在是不是还是单身狗,你就说你气不气?然后他需要每天分别叫几个女朋友起床...

互联网大厂后端必看!Spring Boot 中Runtime执行与停止命令?

你是否曾在使用SpringBoot开发项目时,遇到需要执行系统命令的场景?比如调用脚本进行文件处理,又或是启动外部程序?很多后端开发人员会使用Processexec=Runtime.get...

Linux 常用命令(linux常用的20个命令面试)

日志排查类操作命令...

Java字节码指令:if_icmpgt(0xA3)(java字节码使用的汇编语言)

if_icmpgt是Java字节码中的一条条件跳转指令,其全称是"IfIntegerCompareGreaterThan"。它用于比较两个整数值的大小。如果栈顶的第一个...

外贸干货|如何增加领英的曝光量和询盘

#跨境电商#...

golang执行linux命令(golang调用shell脚本)

需求需要通过openssl生成rsa秘钥,然后保存该秘钥。代码实例packagemainimport("io/ioutil""bytes"&...

LINUX磁盘挂载(linux磁盘挂载到windows)

1、使用root用户查看磁盘挂载情况:fdisk-l2、使用df查看当前磁盘挂载情况,根据和fdisk-l的结果进行对比,查看还有那些磁盘未使用3、挂载:mount磁盘挂载路径...

Linux命令学习——nl命令(linux ln命令的使用)

nl命令主要功能为每一个文件添加行号,每一个输入的文件添加行号后发送到标准输出。当没有文件或文件为-时,读取标准输入...