fork download
  1. <?php
  2. // Simple PHP website - All in one file
  3.  
  4. // Handle form submission
  5. $message = '';
  6. $success = false;
  7.  
  8. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  9. $name = htmlspecialchars($_POST['name'] ?? '');
  10. $email = htmlspecialchars($_POST['email'] ?? '');
  11. $msg = htmlspecialchars($_POST['message'] ?? '');
  12.  
  13. if (empty($name) || empty($email) || empty($msg)) {
  14. $message = "❌ All fields are required!";
  15. } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  16. $message = "❌ Invalid email address!";
  17. } else {
  18. // Send email
  19. $to = "your-email@example.com"; // Change this
  20. $subject = "New Message from $name";
  21. $headers = "From: $email\r\nReply-To: $email\r\n";
  22.  
  23. if (mail($to, $subject, $msg, $headers)) {
  24. $message = "✅ Message sent successfully!";
  25. $success = true;
  26. } else {
  27. $message = "❌ Error sending message!";
  28. }
  29. }
  30. }
  31.  
  32. // Get current page
  33. $page = $_GET['page'] ?? 'home';
  34. ?>
  35.  
  36. <!DOCTYPE html>
  37. <html lang="en">
  38. <head>
  39. <meta charset="UTF-8">
  40. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  41. <title>My PHP Website</title>
  42. <style>
  43. * {
  44. margin: 0;
  45. padding: 0;
  46. box-sizing: border-box;
  47. }
  48.  
  49. body {
  50. font-family: Arial, sans-serif;
  51. line-height: 1.6;
  52. color: #333;
  53. }
  54.  
  55. .container {
  56. max-width: 1000px;
  57. margin: 0 auto;
  58. padding: 0 20px;
  59. }
  60.  
  61. /* Navigation */
  62. nav {
  63. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  64. color: white;
  65. padding: 1rem 0;
  66. box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  67. }
  68.  
  69. nav .container {
  70. display: flex;
  71. justify-content: space-between;
  72. align-items: center;
  73. }
  74.  
  75. .logo {
  76. font-size: 1.8rem;
  77. font-weight: bold;
  78. }
  79.  
  80. nav ul {
  81. list-style: none;
  82. display: flex;
  83. gap: 2rem;
  84. }
  85.  
  86. nav a {
  87. color: white;
  88. text-decoration: none;
  89. padding: 0.5rem 1rem;
  90. border-radius: 5px;
  91. transition: background 0.3s;
  92. }
  93.  
  94. nav a:hover {
  95. background: rgba(255,255,255,0.2);
  96. }
  97.  
  98. nav a.active {
  99. background: rgba(255,255,255,0.3);
  100. font-weight: bold;
  101. }
  102.  
  103. /* Main Content */
  104. main {
  105. padding: 3rem 0;
  106. min-height: calc(100vh - 200px);
  107. }
  108.  
  109. section {
  110. display: none;
  111. }
  112.  
  113. section.active {
  114. display: block;
  115. }
  116.  
  117. h1 {
  118. color: #667eea;
  119. margin-bottom: 1.5rem;
  120. font-size: 2.5rem;
  121. }
  122.  
  123. h2 {
  124. color: #667eea;
  125. margin: 1.5rem 0 1rem 0;
  126. }
  127.  
  128. p {
  129. margin-bottom: 1rem;
  130. font-size: 1.1rem;
  131. line-height: 1.8;
  132. }
  133.  
  134. /* Cards */
  135. .card-grid {
  136. display: grid;
  137. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  138. gap: 2rem;
  139. margin: 2rem 0;
  140. }
  141.  
  142. .card {
  143. background: white;
  144. border: 1px solid #ddd;
  145. border-radius: 8px;
  146. padding: 1.5rem;
  147. box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  148. transition: transform 0.3s;
  149. }
  150.  
  151. .card:hover {
  152. transform: translateY(-5px);
  153. box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  154. }
  155.  
  156. .card h3 {
  157. color: #667eea;
  158. margin-bottom: 0.5rem;
  159. }
  160.  
  161. /* Form */
  162. form {
  163. background: #f4f4f4;
  164. padding: 2rem;
  165. border-radius: 8px;
  166. max-width: 600px;
  167. }
  168.  
  169. form input,
  170. form textarea {
  171. width: 100%;
  172. padding: 12px;
  173. margin: 1rem 0;
  174. border: 1px solid #ddd;
  175. border-radius: 5px;
  176. font-family: Arial, sans-serif;
  177. font-size: 1rem;
  178. }
  179.  
  180. form input:focus,
  181. form textarea:focus {
  182. outline: none;
  183. border-color: #667eea;
  184. box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
  185. }
  186.  
  187. form button {
  188. background: #667eea;
  189. color: white;
  190. padding: 12px 30px;
  191. border: none;
  192. border-radius: 5px;
  193. cursor: pointer;
  194. font-size: 1rem;
  195. transition: background 0.3s;
  196. }
  197.  
  198. form button:hover {
  199. background: #764ba2;
  200. }
  201.  
  202. /* Message */
  203. .message {
  204. padding: 1rem;
  205. border-radius: 5px;
  206. margin: 1rem 0;
  207. font-weight: bold;
  208. font-size: 1.1rem;
  209. }
  210.  
  211. .message.success {
  212. background: #d4edda;
  213. color: #155724;
  214. border: 1px solid #c3e6cb;
  215. }
  216.  
  217. .message.error {
  218. background: #f8d7da;
  219. color: #721c24;
  220. border: 1px solid #f5c6cb;
  221. }
  222.  
  223. /* Footer */
  224. footer {
  225. background: #333;
  226. color: white;
  227. text-align: center;
  228. padding: 2rem 0;
  229. margin-top: 3rem;
  230. }
  231.  
  232. /* Responsive */
  233. @media (max-width: 768px) {
  234. nav ul {
  235. gap: 1rem;
  236. }
  237.  
  238. nav a {
  239. padding: 0.3rem 0.7rem;
  240. font-size: 0.9rem;
  241. }
  242.  
  243. h1 {
  244. font-size: 1.8rem;
  245. }
  246.  
  247. .card-grid {
  248. grid-template-columns: 1fr;
  249. }
  250. }
  251. </style>
  252. </head>
  253. <body>
  254. <!-- Navigation -->
  255. <nav>
  256. <div class="container">
  257. <div class="logo">🚀 MyPHP Site</div>
  258. <ul>
  259. <li><a href="?page=home" class="<?= $page === 'home' ? 'active' : '' ?>">Home</a></li>
  260. <li><a href="?page=about" class="<?= $page === 'about' ? 'active' : '' ?>">About</a></li>
  261. <li><a href="?page=services" class="<?= $page === 'services' ? 'active' : '' ?>">Services</a></li>
  262. <li><a href="?page=contact" class="<?= $page === 'contact' ? 'active' : '' ?>">Contact</a></li>
  263. </ul>
  264. </div>
  265. </nav>
  266.  
  267. <!-- Main Content -->
  268. <main>
  269. <div class="container">*
Success #stdin #stdout #stderr 0.03s 25624KB
stdin
Standard input is empty
stdout
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My PHP Website</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: Arial, sans-serif;
            line-height: 1.6;
            color: #333;
        }

        .container {
            max-width: 1000px;
            margin: 0 auto;
            padding: 0 20px;
        }

        /* Navigation */
        nav {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 1rem 0;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }

        nav .container {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            font-size: 1.8rem;
            font-weight: bold;
        }

        nav ul {
            list-style: none;
            display: flex;
            gap: 2rem;
        }

        nav a {
            color: white;
            text-decoration: none;
            padding: 0.5rem 1rem;
            border-radius: 5px;
            transition: background 0.3s;
        }

        nav a:hover {
            background: rgba(255,255,255,0.2);
        }

        nav a.active {
            background: rgba(255,255,255,0.3);
            font-weight: bold;
        }

        /* Main Content */
        main {
            padding: 3rem 0;
            min-height: calc(100vh - 200px);
        }

        section {
            display: none;
        }

        section.active {
            display: block;
        }

        h1 {
            color: #667eea;
            margin-bottom: 1.5rem;
            font-size: 2.5rem;
        }

        h2 {
            color: #667eea;
            margin: 1.5rem 0 1rem 0;
        }

        p {
            margin-bottom: 1rem;
            font-size: 1.1rem;
            line-height: 1.8;
        }

        /* Cards */
        .card-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 2rem;
            margin: 2rem 0;
        }

        .card {
            background: white;
            border: 1px solid #ddd;
            border-radius: 8px;
            padding: 1.5rem;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            transition: transform 0.3s;
        }

        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        }

        .card h3 {
            color: #667eea;
            margin-bottom: 0.5rem;
        }

        /* Form */
        form {
            background: #f4f4f4;
            padding: 2rem;
            border-radius: 8px;
            max-width: 600px;
        }

        form input,
        form textarea {
            width: 100%;
            padding: 12px;
            margin: 1rem 0;
            border: 1px solid #ddd;
            border-radius: 5px;
            font-family: Arial, sans-serif;
            font-size: 1rem;
        }

        form input:focus,
        form textarea:focus {
            outline: none;
            border-color: #667eea;
            box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
        }

        form button {
            background: #667eea;
            color: white;
            padding: 12px 30px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 1rem;
            transition: background 0.3s;
        }

        form button:hover {
            background: #764ba2;
        }

        /* Message */
        .message {
            padding: 1rem;
            border-radius: 5px;
            margin: 1rem 0;
            font-weight: bold;
            font-size: 1.1rem;
        }

        .message.success {
            background: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }

        .message.error {
            background: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }

        /* Footer */
        footer {
            background: #333;
            color: white;
            text-align: center;
            padding: 2rem 0;
            margin-top: 3rem;
        }

        /* Responsive */
        @media (max-width: 768px) {
            nav ul {
                gap: 1rem;
            }

            nav a {
                padding: 0.3rem 0.7rem;
                font-size: 0.9rem;
            }

            h1 {
                font-size: 1.8rem;
            }

            .card-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>
<body>
    <!-- Navigation -->
    <nav>
        <div class="container">
            <div class="logo">🚀 MyPHP Site</div>
            <ul>
                <li><a href="?page=home" class="active">Home</a></li>
                <li><a href="?page=about" class="">About</a></li>
                <li><a href="?page=services" class="">Services</a></li>
                <li><a href="?page=contact" class="">Contact</a></li>
            </ul>
        </div>
    </nav>

    <!-- Main Content -->
    <main>
        <div class="container">*
stderr
PHP Notice:  Undefined index: REQUEST_METHOD in /home/rk5v7a/prog.php on line 8