3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(isset($_POST['submit_booking'])){ $file="bookings.csv"; if(!file_exists($file)){ file_put_contents($file,"Date,Trip,Flying From,Going To,Departure,Passengers,Name,Email,Phone\n"); } $data=[ date("Y-m-d H:i"), $_POST['trip'], $_POST['from'], $_POST['to'], $_POST['date'], $_POST['passengers'], $_POST['name'], $_POST['email'], $_POST['phone'] ]; $f=fopen($file,"a"); fputcsv($f,$data); fclose($f); $msg="Booking Submitted!"; } ?> <!DOCTYPE html> <html> <head> <style> body{ font-family:Arial; background:#e9f8ff; } .box{ width:900px; margin:50px auto; background:#cfefff; padding:40px; border-radius:25px; } .row{ display:flex; gap:20px; margin-bottom:15px; } input,select{ width:100%; padding:12px; border-radius:8px; border:0; } button{ background:#1e2a6b; color:white; border:none; padding:15px 40px; border-radius:30px; font-size:16px; cursor:pointer; } .center{text-align:center;} .trip label{ border:2px solid #2f79ff; padding:6px 20px; border-radius:6px; margin-right:10px; } </style> </head> <body> <div class="box"> <?php if(isset($msg)) echo "<p style='color:green'>$msg</p>"; ?> <form method="post"> <div class="trip"> <label><input type="radio" name="trip" value="One Way" checked> One Way</label> <label><input type="radio" name="trip" value="Return"> Return</label> </div> <br> <div class="row"> <input name="from" placeholder="Flying From" required> <input name="to" placeholder="Going To" required> </div> <div class="row"> <input type="date" name="date" required> <select name="passengers"> <option>1</option> <option>2</option> <option>3</option> <option>4+</option> </select> <input name="name" placeholder="Full Name" required> </div> <div class="row"> <input type="email" name="email" placeholder="Email" required> <input name="phone" placeholder="Phone"> </div> <br> <div class="center"> <button name="submit_booking">BOOK NOW</button> </div> </form> </div> </body> </html> <?php if(isset($_POST['submit_booking'])){ $file="bookings.csv"; if(!file_exists($file)){ file_put_contents($file,"Date,Trip,Flying From,Going To,Departure,Passengers,Name,Email,Phone\n"); } $data=[ date("Y-m-d H:i"), $_POST['trip'], $_POST['from'], $_POST['to'], $_POST['date'], $_POST['passengers'], $_POST['name'], $_POST['email'], $_POST['phone'] ]; $f=fopen($file,"a"); fputcsv($f,$data); fclose($f); $msg="Booking Submitted!"; } ?> <!DOCTYPE html> <html> <head> <style> body{ font-family:Arial; background:#e9f8ff; } .box{ width:900px; margin:50px auto; background:#cfefff; padding:40px; border-radius:25px; } .row{ display:flex; gap:20px; margin-bottom:15px; } input,select{ width:100%; padding:12px; border-radius:8px; border:0; } button{ background:#1e2a6b; color:white; border:none; padding:15px 40px; border-radius:30px; font-size:16px; cursor:pointer; } .center{text-align:center;} .trip label{ border:2px solid #2f79ff; padding:6px 20px; border-radius:6px; margin-right:10px; } </style> </head> <body> <div class="box"> <?php if(isset($msg)) echo "<p style='color:green'>$msg</p>"; ?> <form method="post"> <div class="trip"> <label><input type="radio" name="trip" value="One Way" checked> One Way</label> <label><input type="radio" name="trip" value="Return"> Return</label> </div> <br> <div class="row"> <input name="from" placeholder="Flying From" required> <input name="to" placeholder="Going To" required> </div> <div class="row"> <input type="date" name="date" required> <select name="passengers"> <option>1</option> <option>2</option> <option>3</option> <option>4+</option> </select> <input name="name" placeholder="Full Name" required> </div> <div class="row"> <input type="email" name="email" placeholder="Email" required> <input name="phone" placeholder="Phone"> </div> <br> <div class="center"> <button name="submit_booking">BOOK NOW</button> </div> </form> </div> </body> </html>
Output for 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
<!DOCTYPE html> <html> <head> <style> body{ font-family:Arial; background:#e9f8ff; } .box{ width:900px; margin:50px auto; background:#cfefff; padding:40px; border-radius:25px; } .row{ display:flex; gap:20px; margin-bottom:15px; } input,select{ width:100%; padding:12px; border-radius:8px; border:0; } button{ background:#1e2a6b; color:white; border:none; padding:15px 40px; border-radius:30px; font-size:16px; cursor:pointer; } .center{text-align:center;} .trip label{ border:2px solid #2f79ff; padding:6px 20px; border-radius:6px; margin-right:10px; } </style> </head> <body> <div class="box"> <form method="post"> <div class="trip"> <label><input type="radio" name="trip" value="One Way" checked> One Way</label> <label><input type="radio" name="trip" value="Return"> Return</label> </div> <br> <div class="row"> <input name="from" placeholder="Flying From" required> <input name="to" placeholder="Going To" required> </div> <div class="row"> <input type="date" name="date" required> <select name="passengers"> <option>1</option> <option>2</option> <option>3</option> <option>4+</option> </select> <input name="name" placeholder="Full Name" required> </div> <div class="row"> <input type="email" name="email" placeholder="Email" required> <input name="phone" placeholder="Phone"> </div> <br> <div class="center"> <button name="submit_booking">BOOK NOW</button> </div> </form> </div> </body> </html> <!DOCTYPE html> <html> <head> <style> body{ font-family:Arial; background:#e9f8ff; } .box{ width:900px; margin:50px auto; background:#cfefff; padding:40px; border-radius:25px; } .row{ display:flex; gap:20px; margin-bottom:15px; } input,select{ width:100%; padding:12px; border-radius:8px; border:0; } button{ background:#1e2a6b; color:white; border:none; padding:15px 40px; border-radius:30px; font-size:16px; cursor:pointer; } .center{text-align:center;} .trip label{ border:2px solid #2f79ff; padding:6px 20px; border-radius:6px; margin-right:10px; } </style> </head> <body> <div class="box"> <form method="post"> <div class="trip"> <label><input type="radio" name="trip" value="One Way" checked> One Way</label> <label><input type="radio" name="trip" value="Return"> Return</label> </div> <br> <div class="row"> <input name="from" placeholder="Flying From" required> <input name="to" placeholder="Going To" required> </div> <div class="row"> <input type="date" name="date" required> <select name="passengers"> <option>1</option> <option>2</option> <option>3</option> <option>4+</option> </select> <input name="name" placeholder="Full Name" required> </div> <div class="row"> <input type="email" name="email" placeholder="Email" required> <input name="phone" placeholder="Phone"> </div> <br> <div class="center"> <button name="submit_booking">BOOK NOW</button> </div> </form> </div> </body> </html>

preferences:
51.01 ms | 870 KiB | 4 Q