« Back to History
simple_post_create.php
|
20260723_000646.php
Initial Domain Snapshot
Copy Code
<?php error_reporting(E_ALL); ini_set('display_errors', 1); require_once __DIR__ . '/config.php'; if (!function_exists('db_connect')) { die('db_connect() not found'); } $pdo = db_connect(); $msg = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $title = trim($_POST['title'] ?? ''); $slug = trim($_POST['slug'] ?? ''); $status = $_POST['status'] ?? 'draft'; $box_style = trim($_POST['box_style'] ?? ''); $meta_title = trim($_POST['meta_title'] ?? ''); $meta_description = trim($_POST['meta_description'] ?? ''); $meta_keywords = trim($_POST['meta_keywords'] ?? ''); $content = trim($_POST['content'] ?? ''); if ($title === '' || $slug === '' || $content === '') { $msg = 'Title, slug aur content required hai'; } else { $st = $pdo->prepare(" INSERT INTO posts (title, slug, status, body_html, box_style, meta_title, meta_description, meta_keywords) VALUES (?, ?, ?, ?, ?, ?, ?, ?) "); try { $st->execute([ $title, $slug, $status, $content, // 👈 AS-IT-IS save $box_style ?: null, $meta_title ?: null, $meta_description ?: null, $meta_keywords ?: null ]); $msg = '✅ Post created successfully'; } catch (PDOException $e) { $msg = '❌ DB Error: ' . $e->getMessage(); } } } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Simple Post Creator</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body{ font-family:system-ui,-apple-system,Segoe UI,sans-serif; background:#f1f1f1; margin:0; } .wrap{ max-width:1100px; margin:20px auto; background:#fff; border:1px solid #ccd0d4; } .header{ padding:12px 16px; border-bottom:1px solid #ccd0d4; font-size:18px; font-weight:600; } .content{ display:flex; gap:20px; padding:16px; } .main{ flex:1; } .sidebar{ width:300px; } input, textarea, select{ width:100%; padding:8px; border:1px solid #ccd0d4; margin-bottom:10px; font-size:14px; } textarea.editor{ min-height:360px; font-family:inherit; } .box{ border:1px solid #ccd0d4; padding:10px; margin-bottom:15px; } .box h4{ margin:0 0 8px; font-size:14px; } button{ background:#2271b1; color:#fff; border:none; padding:8px 14px; border-radius:3px; cursor:pointer; } button:hover{ background:#135e96; } .notice{ padding:10px 16px; background:#f0f6fc; border-bottom:1px solid #ccd0d4; } </style> </head> <body> <div class="wrap"> <div class="header">Add New Post</div> <?php if ($msg): ?> <div class="notice"><?= htmlspecialchars($msg) ?></div> <?php endif; ?> <form method="post"> <div class="content"> <!-- MAIN EDITOR --> <div class="main"> <input name="title" placeholder="Add title" required> <textarea name="content" class="editor" placeholder="Start writing your content here… (paste WordPress content directly)" required ></textarea> </div> <!-- SIDEBAR (WP STYLE) --> <div class="sidebar"> <div class="box"> <h4>Post Settings</h4> <label>Slug</label> <input name="slug" placeholder="post-slug" required> <label>Status</label> <select name="status"> <option value="draft">Draft</option> <option value="published">Published</option> </select> </div> <div class="box"> <h4>Design</h4> <label>Box Style</label> <input name="box_style" placeholder="optional"> </div> <div class="box"> <h4>SEO</h4> <input name="meta_title" placeholder="Meta Title"> <textarea name="meta_description" rows="2" placeholder="Meta Description"></textarea> <textarea name="meta_keywords" rows="2" placeholder="Meta Keywords"></textarea> </div> <button type="submit">Publish</button> </div> </div> </form> </div> </body> </html>