每日博客

php,数据库

$w = 80; //设置图片宽和高
$h = 26;
$str = Array(); //用来存储随机码
$string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";//随机挑选其中4个字符,也可以选择更多,注意循环的时候加上,宽度适当调整
for($i = 0;$i < 4;$i++){
    $str[$i] = $string[rand(0,35)];
    $vcode .= $str[$i];
}
session_start(); //启用超全局变量session
$_SESSION["captcha"] = $vcode;
$im = imagecreatetruecolor($w,$h);
$white = imagecolorallocate($im,255,255,255); //第一次调用设置背景色
$black = imagecolorallocate($im,0,0,0); //边框颜色
imagefilledrectangle($im,0,0,$w,$h,$white); //画一矩形填充
imagerectangle($im,0,0,$w-1,$h-1,$black); //画一矩形框
//生成雪花背景
for($i = 1;$i < 200;$i++){
    $x = mt_rand(1,$w-9);
    $y = mt_rand(1,$h-9);
    $color = imagecolorallocate($im,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
    imagechar($im,1,$x,$y,"*",$color);
}
//将验证码写入图案
for($i = 0;$i < count($str);$i++){
    $x = 13 + $i * ($w - 15)/4;
    $y = mt_rand(3,$h / 3);
    $color = imagecolorallocate($im,mt_rand(0,225),mt_rand(0,150),mt_rand(0,225));
    imagechar($im,5,$x,$y,$str[$i],$color);
}
ob_clean();//原来的程序没有这一栏
header("Content-type:image/png"); //以jpeg格式输出,注意上面不能输出任何字符,否则出错
imagejpeg($im);
imagedestroy($im);
-- phpMyAdmin SQL Dump
-- version 5.1.0
-- https://www.phpmyadmin.net/
--
-- 主机: 127.0.0.1
-- 生成日期: 2021-05-28 14:40:18
-- 服务器版本: 5.7.32-log
-- PHP 版本: 8.0.3

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- 数据库: `flower`
--

-- --------------------------------------------------------

--
-- 表的结构 `flower`
--

CREATE TABLE `flower` (
  `id` int(11) NOT NULL,
  `flower_name` varchar(100) NOT NULL,
  `flower_desc` text NOT NULL,
  `flower_img` varchar(255) NOT NULL,
  `flower_price` varchar(50) NOT NULL,
  `flower_spec` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- 转存表中的数据 `flower`
--

INSERT INTO `flower` (`id`, `flower_name`, `flower_desc`, `flower_img`, `flower_price`, `flower_spec`) VALUES
(22, '', '', '', '', ''),
(23, '78', '45', '11', '100', '43'),
(24, '123', '', '', '', '');

-- --------------------------------------------------------

--
-- 表的结构 `shopping_cart`
--

CREATE TABLE `shopping_cart` (
  `id` int(11) NOT NULL,
  `flower_name` varchar(100) NOT NULL,
  `flower_desc` text NOT NULL,
  `flower_img` varchar(255) NOT NULL,
  `flower_price` varchar(50) NOT NULL,
  `add_time` date NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- 转存表中的数据 `shopping_cart`
--

INSERT INTO `shopping_cart` (`id`, `flower_name`, `flower_desc`, `flower_img`, `flower_price`, `add_time`) VALUES
(25, '78', '77', '1000', '77', '2021-05-27'),
(26, '78', '77', '1000', '77', '2021-05-27'),
(27, '78', '77', '1000', '77', '2021-05-28'),
(28, '78', '77', '1000', '77', '2021-05-28');

-- --------------------------------------------------------

--
-- 表的结构 `user`
--

CREATE TABLE `user` (
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `tel` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- 转存表中的数据 `user`
--

INSERT INTO `user` (`username`, `password`, `email`, `tel`) VALUES
('19832586253', '1234', '1793981249@qq.com', '19832586253');

--
-- 转储表的索引
--

--
-- 表的索引 `flower`
--
ALTER TABLE `flower`
  ADD PRIMARY KEY (`id`);

--
-- 表的索引 `shopping_cart`
--
ALTER TABLE `shopping_cart`
  ADD PRIMARY KEY (`id`);

--
-- 表的索引 `user`
--
ALTER TABLE `user`
  ADD PRIMARY KEY (`username`);

--
-- 在导出的表使用AUTO_INCREMENT
--

--
-- 使用表AUTO_INCREMENT `flower`
--
ALTER TABLE `flower`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;

--
-- 使用表AUTO_INCREMENT `shopping_cart`
--
ALTER TABLE `shopping_cart`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=29;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

 

posted @ 2021-09-15 19:47  谦寻  阅读(42)  评论(0编辑  收藏  举报