run code in 200+ php & hhvm versions
Bugs & Features
<!DOCTYPE html> <html> <head> <style> body{ border:10px solid black; border-style:groove; padding:10px; margin-left:300px; margin-right:300px; } .error{color:red} </style> </head> <body> <?php $fnameerr = $lnameerr = $mailerr = $passerr = $cpasserr = $gendererr = ""; $fname = $lname = $mail = $pass = $cpass = $gender = $file = $add = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if(empty($_POST["fname"])){ $fnameerr = "Please enter your first name";} else{ $fname = test($_POST["fname"]); if(!preg_match("/^[a-zA-Z ]*$/",$fname)) $fnameerr = "Only letters and white spaces are allowed"; } if(empty($_POST["lname"])){ $lnameerr = "Please enter your last name";} else{ $lname = test($_POST["lname"]); if(!preg_match("/^[a-zA-Z ]*$/",$lname)) $lnameerr = "Only letters and white spaces are allowed"; } if(empty($_POST["mail"])){ $mailerr = "Please enter your mail id";} else{ $mail = test($_POST["mail"]); if(!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$mail)) $mailerr = "Please enter a valid mail id"; } if(empty($_POST["pass"])){ $passerr = "Please enter your password";} if(empty($_POST["cpass"])){ $cpasserr = "Please confirm your password";} else{ if($_POST["pass"] != $_POST["cpass"]){ $passerr = "Please enter your password"; $cpasserr="Password is not matching";} } if(empty($_POST["add"])){ $add = "";} else{ $add = test($_POST["add"]);} if (empty($_POST["gender"])) { $gendererr = "Please choose your gender";} else { $gender = test($_POST["gender"]);} } function test($data) { $data = trim($data); $data = stripslashes($data); return $data; } ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <h3><center><u>User Registration Page</u><center></h3> <h5 class="error">* Required fields...</h5> First Name: <input type="text" name="fname"> <span class="error">*<?php echo $fnameerr; ?></span> <br> <br> Last Nmae: <input type="text" name="lname"> <span class="error">*<?php echo $lnameerr; ?></span> <br> <br> E-mail: <input type="text" name="mail"> <span class="error">*<?php echo $mailerr; ?></span> <br> <br> Password: <input type="password" name="pass"> <span class="error">*<?php echo $passerr; ?></span> <br> <br> Confirm password: <input type="password" name="cpass"> <span class="error">*<?php echo $cpasserr; ?></span> <br> <br> Address: <textarea class="xyz" name="add" rows="10" cols="50"></textarea> <br> <br> Gender: <input type="radio" name="gender" value="Male">Male <input type="radio" name="gender" value="Female">Female <span class="error">*<?php echo $gendererr; ?></span> <br> <br> <center><input type="submit" name="sub" value="Submit"></center> <br> </form> <!--<?php if ($_SERVER["REQUEST_METHOD"] == "POST") { echo "Thank you for your registration...<br>"; echo "Your First Name: ".$fname."<br>"; echo "Your Last Name: ".$lname."<br>"; echo "Your E-mail: ".$mail."<br>"; echo "Your address: ".$add."<br>"; echo "Gender: ".$gender."<br>"; } ?>--> <?php /*if ($_SERVER["REQUEST_METHOD"] == "POST")*/ if(isset($_SERVER["REQUEST_METHOD"] == "POST")) { $con = mysqli_connect("localhost","root","","phptask"); if(mysqli_connect_errno()){ echo "Failed to connect to MySql: ".mysqli_connect_error(); } $fname = mysqli_real_escape_string($con,$_POST['fname']); $lname = mysqli_real_escape_string($con,$_POST['lname']); $mail = mysqli_real_escape_string($con,$_POST['mail']); $pass = mysqli_real_escape_string($con,$_POST['pass']); $add = mysqli_real_escape_string($con,$_POST['add']); $gender = mysqli_real_escape_string($con,$_POST['gender']); $sql = "INSERT INTO USER_DETAIL(firstname,lastname,email,password,address,gender)VALUES('$fname','$lname','$mail','$pass','$add','$gender')"; if(!mysqli_query($con,$sql)){ die("Error: ".mysqli_error($con)); } echo "Thank you for your registration.<br>"; echo "Your data has been submitted.<br>"; } ?> </body> </html>
Output for 5.4.0 - 5.4.31
Parse error: syntax error, unexpected '==' (T_IS_EQUAL), expecting ',' or ')' in /in/Ie44l on line 147
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_IS_EQUAL, expecting ',' or ')' in /in/Ie44l on line 147
Process exited with code 255.