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

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

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

  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>

以上代码仅供参考

相关推荐

C++企业级开发规范指南(c++开发gui)

打造高质量、可维护的C++代码标准一、前言C++作为一门功能强大的系统级编程语言,被广泛应用于操作系统、游戏引擎、高性能服务器、数据库系统等领域。知名互联网公司(如Google、Microsoft、腾...

C++|整型的最值、上溢、下溢、截断、类型提升和转换

整数在计算机内以有限字长表示,当超出最值(有限字长)时,需要截断(溢出,求模)操作。不同字长的整型具有不同的值域,混合运算时,需要类型提升和转换。1整形最值在<limit.h>中有整型的...

C++|漫谈STL细节及内部原理(c++ std stl)

1988年,AlexanderStepanov开始进入惠普的PaloAlto实验室工作,在随后的4年中,他从事的是有关磁盘驱动器方面的工作。直到1992年,由于参加并主持了实验室主任BillWo...

C++11新特性总结 (二)(c++11新特性 pdf)

1.范围for语句C++11引入了一种更为简单的for语句,这种for语句可以很方便的遍历容器或其他序列的所有元素vector<int>vec={1,2,3,4,5,6};f...

C++ STL 漫谈(c++中的stl到底指的什么)

标准模板库(StandardTemplateLibrary,STL)是惠普实验室开发的一个函数库和类库。它是由AlexanderStepanov、MengLee和DavidRMusser在...

C++学习教程_C++语言随到随学_不耽误上班_0基础

C++学习教程0基础学C++也可以,空闲时间学习,不耽误上班.2019年C语言新课程已经上线,随到随学,互动性强,效果好!带你征服C++语言,让所有学过和没有学过C++语言的人,或是正准备学习C++语...

C++遍历vector元素的四种方式(c++ 遍历vector)

vector是相同类型对象的集合,集合中的每个对象有个对应的索引。vector常被称为容器(container)。C++中遍历vector的所有元素是相当常用的操作,这里介绍四种方式。1、通过下标访问...

一起学习c++11——c++11中的新增的容器

c++11新增的容器1:array当时的初衷是希望提供一个在栈上分配的,定长数组,而且可以使用stl中的模板算法。array的用法如下:#include<string>#includ...

C++编程实战基础篇:一维数组应用之投票统计

题目描述班上有N个同学,有五位候选人“A,B,C,D,E”,请所有的同学投票并选举出班长,现在请你编写程序来他们计算候选人的得票总数,每位同学投票将以数字的形式投票“12345”分别代表五位候选人,...

C++20 新特性(6):new表达式也支持数组大小推导

new表达式也支持数组大小推导在C++17标准中,在定义并初始化静态数组时,是可以忽略数组大小,然后通过初始化数据来推导数组的大小。但使用new来定义并初始化动态数组时,并不支持这种自动推导数组大...

C++ 结构体(struct)最全详解(c++结构体用法)

一、定义与声明1.先定义结构体类型再单独进行变量定义structStudent{intCode;charName[20];charSex;intA...

自学 C++ 第 6 课 二维数组找最值

键盘输入一个m×n的二维数组,通过C++编程找出元素中的最大值,并输出其所在的位置坐标。例如,输入一个4×5的二维数组,数组元素分别为{{556623749},{578964563},...

从缺陷中学习C/C++:聊聊 C++ 中常见的内存问题

在写C/C++程序时,一提到内存,大多数人会想到内存泄露。内存泄露是一个令人头疼的问题,尤其在开发大的软件系统时。一个经典的现象是,系统运行了10天、1个月都好好的,忽然有一天宕机了:OOM(Out...

C++开发者都应该使用的十个C++11特性(上)

在C++11新标准中,语言本身和标准库都增加了很多新内容,本文只涉及了一些皮毛。不过我相信这些新特性当中有一些,应该成为所有C++开发者的常规装备。你也许看到过许多类似介绍各种C++11特性的文章。下...

深度解读C/C++指针与数组(c++指针和数组的区别)

指针和数组是密切相关的。事实上,指针和数组在很多情况下是可以互换的。例如,一个指向数组开头的指针,可以通过使用指针的算术运算或数组索引来访问数组。今天我们就来聊一聊数组和指针千丝万缕的关系;一维数组与...