3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $nameErr= $surnameErr= $emailErr= $address1Err= $address2Err= $postErr= $countyErr= $usernameErr= $passErr=""; if (isset($_POST['person'])) { include 'db.php'; $customer_name=addslashes($_POST['customer_name']) ; $customer_surname=addslashes($_POST['customer_surname']); $customer_email=addslashes($_POST['customer_email']) ; $address_line_1=addslashes($_POST['address_line_1']); $address_line_2=addslashes($_POST['address_line_2']) ; $customer_post=addslashes($_POST['customer_post']) ; $customer_county=addslashes($_POST['customer_county']) ; $customer_username=addslashes($_POST['customer_username']) ; $customer_password=addslashes($_POST['customer_password']) ; if ($_SERVER["REQUEST_METHOD"] == "POST") if(empty($customer_name)){ $nameErr= "Please provide the customers name.";} if(empty($customer_surname)){ $surnameErr= "Please provide the customers surname.";} if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$customer_email)){ $emailErr = "Please provide a valid Email address."; } $customer_email = strtolower(trim($_POST["customer_email"])); $customer_email = filter_var($customer_email, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH); $results = mysql_query("SELECT customer_id FROM customers WHERE customer_email='$customer_email'"); $email_exist = mysql_num_rows($results); if($email_exist) { $emailErr="That email is already is use.";} if(empty($address_line_1)){ $address1Err= "Please provide a valid address.";} if(!preg_match_all("/^([a-zA-Z]){1}([0-9][0-9]|[0-9]|[a-zA-Z][0-9][a-zA-Z]|[a-zA-Z][0-9][0-9]|[a-zA-Z][0-9]){1}([ ])([0-9][a-zA-z][a-zA-z]){1}$/", $customer_post)) {$postErr="please provide a valid postcode.";} if(isset($_REQUEST['customer_county']) && $_REQUEST['customer_county'] == '0') { $countyErr = "Please pick the county in which you inhabit.";} if(empty($customer_username)){ $usernameErr= "please provide a valid username.";} if(isset($_POST["customer_username"])) { $customer_username = strtolower(trim($_POST["customer_username"])); $customer_username = filter_var($customer_username, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH); $results = mysql_query("SELECT customer_id FROM customers WHERE customer_username='$customer_username'"); $username_exist = mysql_num_rows($results); if($username_exist) { $usernameErr="That name is unavailable.";}} if (!preg_match_all('$\S*(?=\S{6,})(?=\S*[a-z])(?=\S*[A-Z])(?=\S*[\d])\S*$', $customer_password)) { $passErr="Please provide a valid password."; } if($nameErr=="" and $surnameErr=="" and $emailErr=="" and $address1Err=="" and $postErr=="" and $countyErr=="" and $usernameErr=="" and $passErr==""){ mysql_query("INSERT INTO `customers`(customer_name,customer_surname,customer_email,address_line_1,address_line_2,customer_post,customer_county,customer_username,customer_password) VALUES ('$customer_name','$customer_surname','$customer_email','$address_line_1','$address_line_2','$customer_post','$customer_county','$customer_username',md5('$customer_password')")"); }} ?> <!DOCTYPE HTML> <html> <head> <meta content="text/javascript"/> <link rel="stylesheet" type="text/css" href="css/blitzer/backsty.css"> <script type="text/javascript"> window.onload=function(){ var tfrow = document.getElementById('tfhover').rows.length; var tbRow=[]; for (var i=1;i<tfrow;i++) { tbRow[i]=document.getElementById('tfhover').rows[i]; tbRow[i].onmouseover = function(){ this.style.backgroundColor = '#F6D4D4'; }; tbRow[i].onmouseout = function() { this.style.backgroundColor = '#EB8686'; }; } }; </script> <script type="text/javascript"> function confirm_click(customer_name) { return confirm("Are you sure you want to delete "+ customer_name +" from the database ?"); } function validateEmail() { var emailID = document.userForm.customer_email.value; atpos = emailID.indexOf("@"); dotpos = emailID.lastIndexOf("."); if (atpos < 1 || ( dotpos - atpos < 2 )) { alert("Please provide correct email ID") document.userForm.customer_email.focus() ; return false; } return( true ); } function validatePost() { var postID = document.userForm.customer_post.value; regPostcode = /^([a-zA-Z]){1}([0-9][0-9]|[0-9]|[a-zA-Z][0-9][a-zA-Z]|[a-zA-Z][0-9][0-9]|[a-zA-Z][0-9]){1}([ ])([0-9][a-zA-z][a-zA-z]){1}$/; if(regPostcode.test(postID) == false) { alert("Please provide the correct Postcode"); document.userForm.customer_post.focus() ; return false; } return ( true ) ; } function validate() { if( document.userForm.customer_name.value == "" ) { alert("Please provide the customer name!"); document.userForm.customer_name.focus() ; return false; } if( document.userForm.customer_surname.value == "" ) { alert( "Please provide the customer surname!" ); document.userForm.customer_surname.focus() ; return false; } if( document.userForm.customer_email.value == "" ) { alert( "Please provide the correct Email!" ); document.userForm.customer_email.focus() ; return false; }else{ var ret = validateEmail(); if( ret == false ) { return false; } } if( document.userForm.address_line_1.value == "") { alert( "Please provide the correct address" ); document.userForm.address_line_1.focus() ; return false; } if( document.userForm.customer_post.value == "" ) { alert( "Please provide the correct postcode!" ); document.userForm.customer_post.focus() ; return false; }else{ var ret = validatePost(); if( ret == false ) { return false; } } if( document.userForm.customer_county.value == "0" ) { alert( "Please provide your county!" ); document.userForm.customer_username.focus() ; return false; } if( document.userForm.customer_username.value == "" ) { alert( "Please provide a valid Username!" ); document.userForm.customer_username.focus() ; return false; } var passw = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20}$/; if(document.userForm.customer_password.value.match(passw)) { return true; } else { alert('Please provide a valid password which contains 6 to 20 characters which contain at least one numeric digit, one uppercase and one lowercase letter.') return false; } } </script> </head> <body> <form method="LINK" ACTION="index_mod.php"> <input type="submit" class="button2" value="Admin Home" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <h1>Customer Management</h1> </form> <div id="content"> <table> <form onsubmit="return(validate());" name="userForm" method="post" autocomplete="off"> <tr> <td>Name</td> <td><input type="text" class="textbox" name="customer_name" /></td><td> <span class="error"> <?php echo $nameErr ?></span> </td> </tr><tr> <td>Surname</td> <td><input type="text" class="textbox" name="customer_surname" /></td><td> <span class="error"> <?php echo $surnameErr ?></span> </td> </tr><tr> <td>Email</td> <td><input type="text" class="textbox" name="customer_email" /></td><td> <span class="error"> <?php echo $emailErr ?></span> </td> </tr><tr> <td>Address1</td> <td><input type="text" class="textbox" name="address_line_1" /></td><td> <span class="error"> <?php echo $address1Err ?></span> </td> </tr><tr> <td>Address2</td> <td><input type="text" class="textbox" name="address_line_2" /></td> </tr><tr> <td>Post code</td> <td><input type="text" class="textbox" name="customer_post" /></td><td> <span class="error"> <?php echo $postErr ?></span> </td> </tr><tr> <td>County<td> <select class="textbox" name="customer_county"> <option value="0">Please select</option> <option>Aberdeenshire</option> <option>Anglesey</option> <option>Angus (Forfarshire)</option> <option>Antrim</option> <option>Argyll</option> <option>Armagh</option> <option>Avon</option> <option>Ayrshire</option> <option>Banffshire</option> <option>Bedfordshire</option> <option>Berkshire</option> <option>Berwickshire</option> <option>Brecknockshire</option> <option>Buckinghamshire</option> <option>Bute</option> <option>Caernarfonshire</option> <option>Caithness</option> <option>Cambridgeshire and Isle of Ely</option> <option>Cambridgeshire</option> <option>Cardiganshire</option> <option>Carmarthenshire</option> <option>Cheshire</option> <option>City of Aberdeen</option> <option>City of Belfast</option> <option>City of Bristol</option> <option>City of Dundee</option> <option>City of Edinburgh</option> <option>City of Glasgow</option> <option>City of London</option> <option>City of Londonderry</option> <option>Clackmannanshire</option> <option>Cleveland</option> <option>Clwyd</option> <option>Cornwall</option> <option>County</option> <option>Cromartyshire</option> <option>Cumberland</option> <option>Cumbria</option> <option>Denbighshire</option> <option>Derbyshire</option> <option>Devon</option> <option>Dorset</option> <option>Down</option> <option>Dumfriesshire</option> <option>Dunbartonshire (Dumbarton)</option> <option>Durham</option> <option>Dyfed</option> <option>East Lothian (Haddingtonshire)</option> <option>East Suffolk</option> <option>East Sussex</option> <option>Essex</option> <option>Fermanagh</option> <option>Fife</option> <option>Flintshire</option> <option>Glamorgan</option> <option>Gloucestershire</option> <option>Greater London</option> <option>Greater Manchester</option> <option>Gwent</option> <option>Gwynedd</option> <option>Hampshire (County of Southampton)</option> <option>Hereford and Worcester</option> <option>Herefordshire</option> <option>Hertfordshire</option> <option>Humberside</option> <option>Huntingdon and Peterborough</option> <option>Huntingdonshire</option> <option>Inverness-shire</option> <option>Isle of Ely</option> <option>Isle of Wight</option> <option>Kent</option> <option>Kincardineshire</option> <option>Kinross-shire</option> <option>Kirkcudbrightshire</option> <option>Lanarkshire</option> <option>Lancashire</option> <option>Leicestershire</option> <option>Lincolnshire, Parts of Holland</option> <option>Lincolnshire, Parts of Kesteven</option> <option>Lincolnshire, Parts of Lindsey</option> <option>Lincolnshire</option> <option>London</option> <option>Londonderry</option> <option>Merionethshire</option> <option>Merseyside</option> <option>Mid Glamorgan</option> <option>Middlesex</option> <option>Midlothian (County of Edinburgh)</option> <option>Monmouthshire</option> <option>Montgomeryshire</option> <option>Moray (Elginshire)</option> <option>Nairnshire</option> <option>Norfolk</option> <option>North Humberside</option> <option>North Yorkshire</option> <option>Northamptonshire</option> <option>Northumberland</option> <option>Nottinghamshire</option> <option>Orkney</option> <option>Oxfordshire</option> <option>Peeblesshire</option> <option>Pembrokeshire</option> <option>Perthshire</option> <option>Powys</option> <option>Radnorshire</option> <option>Renfrewshire</option> <option>Ross and Cromarty</option> <option>Ross-shire</option> <option>Roxburghshire</option> <option>Rutland</option> <option>Selkirkshire</option> <option>Shetland (Zetland)</option> <option>Shropshire (Salop)</option> <option>Soke of Peterborough</option> <option>Somerset</option> <option>South Glamorgan</option> <option>South Humberside</option> <option>South Yorkshire</option> <option>Staffordshire</option> <option>Stirlingshire</option> <option>Suffolk</option> <option>Surrey</option> <option>Sussex</option> <option>Sutherland</option> <option>Tyne and Wear</option> <option>Tyrone</option> <option>Warwickshire</option> <option>West Glamorgan</option> <option>West Lothian (Linlithgowshire)</option> <option>West Midlands</option> <option>West Suffolk</option> <option>West Sussex</option> <option>West Yorkshire</option> <option>Westmorland</option> <option>Wigtownshire</option> <option>Wiltshire</option> <option>Worcestershire</option> <option>Yorkshire, East Riding</option> <option>Yorkshire, North Riding</option> <option>Yorkshire, West Riding</option> <option>Yorkshire</option> </select><td> <span class="error"> <?php echo $countyErr ?></span> </td> </tr><tr> <td>Username</td> <td><input class="textbox" type="text" name="customer_username" id="customer_username" /><span id="user-result"></span></td><td><span class="error"> <?php echo $usernameErr ?></span> </td> </tr><tr> <td>Password</td> <td><input class="textbox" type="text" name="customer_password" /></td><td> <span class="error"> <?php echo $passErr ?></span> </td> </tr><tr> <td>&nbsp;</td> <td><input type="submit" name="person" class="button1" /></td> </tr></form> </table> </div> <script type="text/javascript" src="js/jquery-1.9.0.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#customer_username").keyup(function (e) { //removes spaces from username $(this).val($(this).val().replace(/\s/g, '')) var customer_username = $(this).val(); if(customer_username.length < 4){$("#user-result").html('');return;} if(customer_username.length >= 4){ $("#user-result").html('<img src="imgs/ajax-loader.gif" />'); $.post('check_username.php', {'customer_username':customer_username}, function(data) { $("#user-result").html(data); }); } }); }); </script> </form> <div id="stock"> <?php include("db.php"); $result=mysql_query("SELECT * FROM customers"); echo "<table id='tfhover'class='tftable' border='1'>\n"; echo "<tr>\n"; echo "<th>ID</th>\n"; echo "<th>Name</th>\n"; echo "<th>Surname</th>\n"; echo "<th>Email</th>\n"; echo "<th>Adress1</th>\n"; echo "<th>Adress2</th>\n"; echo "<th>Post code</th>\n"; echo "<th>County</th>\n"; echo "<th>Username</th>\n"; echo"<tr>\n"; while($test = mysql_fetch_array($result)){$id = $test['customer_id']; echo"<tr align='left'>\n"; echo"<td><font color='black'>" .$test['customer_id']. "</font></td>\n"; echo"<td><font color='black'>" .$test['customer_name']. "</font></td>\n"; echo"<td><font color='black'>". $test['customer_surname']. "</font></td>\n"; echo"<td><font color='black'>". $test['customer_email']. "</font></td>\n"; echo"<td><font color='black'>". $test['address_line_1']. "</font></td>\n"; echo"<td><font color='black'>". $test['address_line_2']. "</font></td>\n"; echo"<td><font color='black'>". $test['customer_post']. "</font></td>\n"; echo"<td><font color='black'>". $test['customer_county']. "</font></td>\n"; echo"<td><font color='black'>". $test['customer_username']."</font></td>\n"; echo"<td class='link'><a class='links' href ='custdata1.php?customer_id=$id'>Edit</a></td>\n"; echo"<td class=\"link\"><a onclick=\"return confirm_click('".$test['customer_name']."');\" class='links1' href='delcustdata.php?customer_id=$id'>Delete</a></td>\n"; echo "</tr>";} echo"</table>"; mysql_close($conn);?> </div> </body> </html>
Output for 5.4.0 - 5.4.27
Parse error: syntax error, unexpected '");' (T_CONSTANT_ENCAPSED_STRING) in /in/1eiQA on line 75
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.28
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /in/1eiQA on line 75
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /in/1eiQA on line 75
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/1eiQA on line 75
Process exited with code 255.