3v4l.org

run code in 300+ PHP versions simultaneously
$isbn = $_POST['ISBN'];$title = trim($_REQUEST['title']);$description = trim($_REQUEST['description']);$price = trim($_REQUEST['price']);$publisher = trim($_REQUEST['publisher']);$pubdate = trim($_REQUEST['pubdate']);$edition = trim($_REQUEST['edition']);$pages = trim($_REQUEST['pages']);$catname = trim($_REQUEST['CategoryName']);$firstname = trim($_REQUEST['strFName']);$lastname =trim( $_REQUEST['strLName']);////////////////////////////////////////////////////////////////$errors = array(); if (!preg_match ('/^[0-9]+{13}&/', $isbn)) {$errors[] = 'ISBN must be numeric and 13 characters long';} if (empty($_POST["title"])) {$errors[] = 'Title cannot be empty';} if (empty($_POST["description"])) {$errors[] = 'Description cannot be empty';} if (!preg_match ('/^$[0-9\.]&/', $price)) {$errors[] = 'Price must be in $USD';} if (empty($_POST["publisher"])) {$errors[] = 'Publisher cannot be empty';} if (!preg_match ('!^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d!', $pubdate)) {$errors[] = 'Date must be in dd-mm-yyyy';} if (!preg_match ('/^[0-9]{2}$/', $edition)) {$errors[] = 'Edition must be numeric and 2 digits long';} if (!preg_match ('/^[0-9]$/', $pages)) {$errors[] = 'Pages must be numeric';} if (empty($_POST["catname"])) {$errors[] = 'Category cannot be empty';} if (empty($_POST["firstname"])) {$errors[] = 'First Name cannot be empty';} if (empty($_POST["lastname"])) {$errors[] = 'Last Name cannot be empty';} if (empty($errors)) { $sql_ba = "INSERT INTO bookauthors (strFName, strLName) values('$firstname', '$lastname');"; $sql_bd = "INSERT INTO bookdescriptions (ISBN, title, description, price, publisher, pubdate, edition, pages) values('$isbn', '$title', '$description', '$price', '$publisher', '$pubdate', '$edition', '$pages');"; $sql_bab = "INSERT INTO bookauthorsbooks (ISBN, AuthorID) values('$isbn', LAST_INSERT_ID());"; $sql_bc = "INSERT INTO bookcategories (CategoryName) values('$catname');"; $sql_bcb = "INSERT INTO bookcategoriesbooks (CategoryID, ISBN) VALUES(LAST_INSERT_ID(), '$isbn');"; $sql = $sql_ba . $sql_bd . $sql_bab . $sql_bc . $sql_bc; echo $sql; $success = ''; if(mysqli_multi_query($conn, $sql)) { do { $success+=mysqli_affected_rows($conn); } while (mysqli_more_results($conn) && mysqli_next_result($conn)); } if ($success == 5) { echo "All records have been successfully inserted"; } } else { echo '<h1>Error!</h1> <p style="color:red;">The following error(s) occurred:<br />'; foreach ($errors as $msg) { echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p>'; }/////////////////////////////////////////////////////////////////} mysqli_close($conn);?><form action="insertbook.php" method="post"> <fieldset><legend>Enter your information in the form below:</legend> <div id="field"> <label for="ISBN">ISBN: </label> <input type="text" name="ISBN" value="<?php if (isset($isbn)) echo htmlentities($isbn);?>"/> </div> <div id="field"> <label for="title">Title: </label> <input type="text" name="title" value="<?php if (isset($title)) echo htmlentities($title);?>"/> </div> <div id="field"> <label for="description">Description: </label> <input type="text" name="description" value="<?php if (isset($description)) echo htmlentities($description);?>"/> </div> <div id="field"> <label for="price">Price: </label> <input type="text" name="price" value="<?php if (isset($price)) echo htmlentities($price);?>"/> </div> <div id="field"> <label for="publisher">Publisher: </label> <input type="text" name="publisher" value="<?php if (isset($publisher)) echo htmlentities($publisher);?>"/> </div> <div id="field"> <label for="pubdate">Publish Date: </label> <input type="text" name="pubdate" value="<?php if (isset($pubdate)) echo htmlentities($pubdate);?>"/> </div> <div id="field"> <label for="edition">Edition: </label> <input type="text" name="edition" value="<?php if (isset($edition)) echo htmlentities($edition);?>"/> </div> <div id="field"> <label for="pages">Pages: </label> <input type="text" name="pages" value="<?php if (isset($pages)) echo htmlentities($pages); ?>"/> </div> <div id="field"> <label for="CategoryName">Category Name: </label> <input type="text" name="CategoryName" value="<?php if (isset($CategoryName)) echo htmlentities($CategoryName);?>"/> </div> <div id="field"> <label for="strFName">Author First Name: </label> <input type="text" name="strFName" value="<?php if (isset($strFName)) echo htmlentities($strFName);?>"/> </div> <div id="field"> <label for="strLName">Author Last Name</label> <input type="text" name="strLName" value="<?php if (isset($strLName)) echo htmlentities($strLName);?>"/> </div> <br> <input id="submit" type="submit" value="Submit" name="submit"> </fieldset></form><?php (include("footer.html")) or die("ERROR");?>
Output for git.master, git.master_jit, rfc.property-hooks
$isbn = $_POST['ISBN'];$title = trim($_REQUEST['title']);$description = trim($_REQUEST['description']);$price = trim($_REQUEST['price']);$publisher = trim($_REQUEST['publisher']);$pubdate = trim($_REQUEST['pubdate']);$edition = trim($_REQUEST['edition']);$pages = trim($_REQUEST['pages']);$catname = trim($_REQUEST['CategoryName']);$firstname = trim($_REQUEST['strFName']);$lastname =trim( $_REQUEST['strLName']);////////////////////////////////////////////////////////////////$errors = array(); if (!preg_match ('/^[0-9]+{13}&/', $isbn)) {$errors[] = 'ISBN must be numeric and 13 characters long';} if (empty($_POST["title"])) {$errors[] = 'Title cannot be empty';} if (empty($_POST["description"])) {$errors[] = 'Description cannot be empty';} if (!preg_match ('/^$[0-9\.]&/', $price)) {$errors[] = 'Price must be in $USD';} if (empty($_POST["publisher"])) {$errors[] = 'Publisher cannot be empty';} if (!preg_match ('!^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d!', $pubdate)) {$errors[] = 'Date must be in dd-mm-yyyy';} if (!preg_match ('/^[0-9]{2}$/', $edition)) {$errors[] = 'Edition must be numeric and 2 digits long';} if (!preg_match ('/^[0-9]$/', $pages)) {$errors[] = 'Pages must be numeric';} if (empty($_POST["catname"])) {$errors[] = 'Category cannot be empty';} if (empty($_POST["firstname"])) {$errors[] = 'First Name cannot be empty';} if (empty($_POST["lastname"])) {$errors[] = 'Last Name cannot be empty';} if (empty($errors)) { $sql_ba = "INSERT INTO bookauthors (strFName, strLName) values('$firstname', '$lastname');"; $sql_bd = "INSERT INTO bookdescriptions (ISBN, title, description, price, publisher, pubdate, edition, pages) values('$isbn', '$title', '$description', '$price', '$publisher', '$pubdate', '$edition', '$pages');"; $sql_bab = "INSERT INTO bookauthorsbooks (ISBN, AuthorID) values('$isbn', LAST_INSERT_ID());"; $sql_bc = "INSERT INTO bookcategories (CategoryName) values('$catname');"; $sql_bcb = "INSERT INTO bookcategoriesbooks (CategoryID, ISBN) VALUES(LAST_INSERT_ID(), '$isbn');"; $sql = $sql_ba . $sql_bd . $sql_bab . $sql_bc . $sql_bc; echo $sql; $success = ''; if(mysqli_multi_query($conn, $sql)) { do { $success+=mysqli_affected_rows($conn); } while (mysqli_more_results($conn) && mysqli_next_result($conn)); } if ($success == 5) { echo "All records have been successfully inserted"; } } else { echo '<h1>Error!</h1> <p style="color:red;">The following error(s) occurred:<br />'; foreach ($errors as $msg) { echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p>'; }/////////////////////////////////////////////////////////////////} mysqli_close($conn);?><form action="insertbook.php" method="post"> <fieldset><legend>Enter your information in the form below:</legend> <div id="field"> <label for="ISBN">ISBN: </label> <input type="text" name="ISBN" value=""/> </div> <div id="field"> <label for="title">Title: </label> <input type="text" name="title" value=""/> </div> <div id="field"> <label for="description">Description: </label> <input type="text" name="description" value=""/> </div> <div id="field"> <label for="price">Price: </label> <input type="text" name="price" value=""/> </div> <div id="field"> <label for="publisher">Publisher: </label> <input type="text" name="publisher" value=""/> </div> <div id="field"> <label for="pubdate">Publish Date: </label> <input type="text" name="pubdate" value=""/> </div> <div id="field"> <label for="edition">Edition: </label> <input type="text" name="edition" value=""/> </div> <div id="field"> <label for="pages">Pages: </label> <input type="text" name="pages" value=""/> </div> <div id="field"> <label for="CategoryName">Category Name: </label> <input type="text" name="CategoryName" value=""/> </div> <div id="field"> <label for="strFName">Author First Name: </label> <input type="text" name="strFName" value=""/> </div> <div id="field"> <label for="strLName">Author Last Name</label> <input type="text" name="strLName" value=""/> </div> <br> <input id="submit" type="submit" value="Submit" name="submit"> </fieldset></form> Warning: include(): open_basedir restriction in effect. File(footer.html) is not within the allowed path(s): (/tmp:/in:/etc) in /in/mPP9g on line 1 Warning: include(footer.html): Failed to open stream: Operation not permitted in /in/mPP9g on line 1 Warning: include(): Failed opening 'footer.html' for inclusion (include_path='.:') in /in/mPP9g on line 1 ERROR

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.31 ms | 413 KiB | 8 Q