PHP - Register Form Password Validation Error Message
I am trying to use the new way of validating the entered email in a register form.
Code: [Select] /* REGISTER FORM */ // check if submit button has been clicked if (isset($_POST['submit_signup'])) { // process and assign variables after post submit button has been clicked $user_email = strip_tags(trim($_POST['email'])); $user_email = filter_var($user_email, FILTER_VALIDATE_EMAIL); $nickname = strip_tags(trim($_POST['nickname'])); $password = $_POST['password']; $repassword = $_POST['repassword']; $month = $_REQUEST['month']; $day = $_REQUEST['day']; $year = $_REQUEST['year']; $dob = $year . "-" . $month . "-" . $day; $find_us_question = strip_tags(trim($_POST['find_us_question'])); // connect to database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $check_query = "SELECT * FROM user WHERE nickname = '$nickname'"; $check_connect = mysqli_query($dbc, $check_query) or die(mysqli_error($dbc)); $check_count = mysqli_num_rows($check_connect); // Check if the email exists twice $query_get = "SELECT email FROM user WHERE email = '$user_email'"; $query_run = mysqli_query($dbc, $query_get); $num_rows = mysqli_num_rows($query_run); // check if username is already taken if ($check_count != 0) { echo "Username already exists!"; } elseif ($num_rows != 0) { echo "This email address is already registered in the database, you can not register it twice."; // check if fields are empty } elseif (empty($user_email) || empty($nickname) || empty($password) || empty($day) || empty($month) || empty($year)) { echo "Please fill out all the fields!"; // check char length of input data } elseif (strlen($nickname) > 30 || strlen($user_email) > 50) { echo "Maximum allowed character length for nickname/firstname/lastname are 30 characters!"; // check password char length } elseif (strlen($password) > 25 || strlen($password) < 6) { echo "Your password must be between 6 and 25 characters!"; // check if passwords match with each other } elseif ($password != $repassword) { echo "Please make sure your passwords are matching!"; } else { // encrypt password $password = sha1($password); I would like to implement now an error message stating something along the lines that the entered email address is not valid, how would I have to do the if statement to check the condition? Similar TutorialsHello, I'm working on a register script, and basically I would like the user to repeat their password. And I would like PHP to compare the to passwords, and if they both match then it continues, whereas if they don't match it calls an error. Here is what I have so far: Form: Consists of 2 text fields - subpass, and subconfirmpass PHP: $field = "subpass"; if(!$subpass == $subconfirmpass){ $form->setError($field, "* Passwords do not match"); } $field is referring to the text fields in where the user inputs their password $form is keeping track of errors in user submitted forms and the form field values that were entered correctly. I would appreciate your help, Thanks Hi guys I am working on adding a third party php members register and login into a clients web site but every time I try the regidter page is shows me this error message. Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in /home/cpassoc2/public_html/register-exec.php on line 15 Failed to connect to server: Access denied for user 'username'@'localhost' (using password: YES) This is what i have in the config.php page. <?php define('DB_HOST', 'localhost'); define('DB_USER', 'cpassoc2-memark'); define('DB_PASSWORD', '?????????'); password replaced define('DB_DATABASE', 'cpassoc2-me'); ?> I have set up the my SQL within the control panel of the site, So do i need to do any thing else???, what am i missing???. Mark..... Hello, I have coded a contact form in PHP and I want to know, if according to you, it is secure! I am new in PHP, so I want some feedback from you. Moreover, I have also two problems based on the contact form. It is a bit complicated to explain, thus, I will break each of my problem one by one. FIRST:The first thing I want to know, is if my contact form secure according to you: The HTML with the PHP codes: Code: [Select] <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { //Assigning variables to elements $first = htmlentities($_POST['first']); $last = htmlentities($_POST['last']); $sub = htmlentities($_POST['subject']); $email = htmlentities($_POST['email']); $web = htmlentities($_POST['website']); $heard = htmlentities($_POST['heard']); $comment = htmlentities($_POST['message']); $cap = htmlentities($_POST['captcha']); //Declaring the email address with body content $to = 'alithebestofall2010@gmail.com'; $body ="First name: '$first' \n\n Last name: '$last' \n\n Subject: '$sub' \n\n Email: '$email' \n\n Website: '$web' \n\n Heard from us: '$heard' \n\n Comments: '$comment'"; //Validate the forms if (empty($first) || empty($last) || empty($sub) || empty($email) || empty($comment) || empty($cap)) { echo '<p class="error">Required fields must be filled!</p>'; header ('refresh= 3; url= index.php'); return false; } elseif (filter_var($first, FILTER_VALIDATE_INT) || filter_var($last, FILTER_VALIDATE_INT)) { echo '<p class="error">You cannot enter a number as either the first or last name!</p>'; return false; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo '<p class="error">Incorrect email address!</p>'; return false; } elseif (!($cap === '12')){ echo '<p class="error">Invalid captcha, try again!</p>'; return false; } else { mail ($to, $sub, $body); echo '<p class="success">Thank you for contacting us!</p>'; } } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <p>Your first name: <span class="required">*</span></p> <p><input type="text" name="first" size="40" placeholder="Ex: Paul"/></p> <p>Your last name: <span class="required">*</span></p> <p><input type="text" name="last" size="40" placeholder="Ex: Smith"/></p> <p>Subject: <span class="required">*</span></p> <p><input type="text" name="subject" size="40" placeholder="Ex: Contact"/></p> <p>Your email address: <span class="required">*</span></p> <p><input type="text" name="email" size="40" placeholder="Ex: example@xxx.com"/></p> <p>Website:</p> <p><input type="text" name="website" size="40" placeholder="Ex: http//:google.com"/></p> <p>Where you have heard us?: <span class="required">*</span></p> <p><select name="heard"> <option>Internet</option> <option>Newspapers</option> <option>Friends or relatives</option> <option>Others</option> </select></p> <p>Your message: <span class="required">*</span></p> <p><textarea cols="75" rows="20" name="message"></textarea></p> <p>Are you human? Sum this please: 5 + 7 = ?: <span class="required">*</span></p></p> <p><input type="text" name="captcha" size="10"/></p> <p><input type="submit" name="submit" value="Send" class="button"/> <input type="reset" value="Reset" class="button"/></p> </form> SECOND PROBLEM:If a user has made a mistake, he gets the error message so that he can correct! However, when a mistake in the form occurs, all the data the user has entered are disappeared! I want the data to keep appearing so that the user does not start over again to fill the form. THIRD: When the erro message is displayed to notify the user that he made a mistake when submitting the form, the message is displaying on the top of the page. I want it to appear below each respective field. How to do that? In JQuery it is simple, but in PHP, I am confusing! As some of y'all may not know, I am new to this php coding stuff so if anything does not work the way I want it to, it goes to the forum. And this is the case when just after I solved a problem with my first contact form, I run into another problem again. My latest problem involves the form error thing that tells you that you did not enter any required fields. After I added a error message thing to my contact page and tested it, it doesn't show up. Oh and here's the code: Code: [Select] <?php if ($missing || $errors) { ?> <div id="maincontent"> <p class="warning">You did not enter the required information. Please try again.</p></div> Here is what makes up my contact form. Code: [Select] <?php $errors = array(); $missing = array(); if (isset($_POST['send'])) { $to = 'tate.mikey@gmail.com'; $subject = 'New Feedback Received on MikeyTateLive Productions website'; $expected = array('name', 'email', 'comments'); $required = array('name', 'comments'); require ('/www/zymichost.com/m/t/l/mtlproductions/htdocs/processmail.inc.php'); } ?> <div id="wrapper"> <div id="maincontent"> <p>*=required</p> </div> </div> <form id="feedback" method="get" action=""> <p> <label for="name">*Name:</label></br> <input name="name" id="name" type="text" class="formbox"> </p> <p> <label for="email">Email:</label></br> <input name="email" id="email" type="text" class="formbox"> </p> <p> <label for="comments">*Comments:</label></br> <textarea name="comments" id="comments" cols="60" rows="8"></textarea> </p> <p> <input name="send" id="send" type="submit" value="Send" </p> </form> This is my registering script: <?php include('connectvars.php'); $user_email = strip_tags(trim($_POST['email'])); $firstname = strip_tags(trim($_POST['firstname'])); $lastname = strip_tags(trim($_POST['lastname'])); $nickname = strip_tags(trim($_POST['nickname'])); $password = strip_tags($_POST['password']); $repassword = strip_tags($_POST['repassword']); $dob = $_POST['dob']; $find_us_question = strip_tags(trim($_POST['find_us_question'])); if (isset($_POST['submit_signup'])) { if ((empty($user_email)) || (empty($firstname)) || (empty($lastname)) || (empty($nickname)) || (empty($password)) || (empty($dob))) { echo "Please fill out all the fields!"; } else { // check char length of input data if (($nickname > 30) || ($firstname > 30) || ($lastname > 30) || ($user_email > 50)) { echo "Your nickname, first- and/or lastname seem to be too long, please make sure you have them below the maximum allowed length of 30 characters!"; } else { // check password char length if (($password > 25) || ($password < 6)) { echo "Your password must be between 6 and 25 characters!"; } else { // encrypt password $password = sha1($password); $repassword = sha1($repassword); if ($password != $repassword) { echo "Please make sure your passwords are matching!"; } else { $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query = sprintf("INSERT INTO user (firstname, lastname, nickname, password, email, dob, doj) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', now())", mysqli_real_escape_string($dbc, $firstname), mysqli_real_escape_string($dbc, $lastname), mysqli_real_escape_string($dbc, $nickname), mysqli_real_escape_string($dbc, $password), mysqli_real_escape_string($dbc, $user_email), $dob); mysqli_query($dbc, $query); mysqli_close($dbc); echo "You have been successfully registered!"; } } } } } ?> A bunch of nested if statements, the read-ability gets worse after a while, I'm new to programming so I don't know if there's a better more read-able solution. Anyway, every time I try to sign up it's printing out the echo message: "Your password must be between 6 and 25 characters!" Which derives from: // check password char length if (($password > 25) || ($password < 6)) { echo "Your password must be between 6 and 25 characters!"; } else { EVEN if I stay between 6 and 25 characters it's still printing out this error message, let's say I have a password of 8 characters, and I've entered everything else correctly, it's still giving me all the time this error message, and I can not figure out why. Hello all, I'm new to PHP and new to this forum (although I have benefitted from your help already -cheers!). However, this time I cannot find the answer I need/recognise/understand.. I have a form and want to conduct tests on each field returning an error message as a session variable if the test fails. The test will be different for some of the fields, and the error message is specific to each field. If there is an error in any one of the fields I want to be redirected to a failure page where all of the error messages are displayed, otherwise I am sent on to another page. I have already written and tested a function to sanitise the incoming form data, so that's not a problem - it's just how to loop through and test. I can guess that there are many ways to do this but I need to understand why one option is better than another, and follow the syntax used (it's all part of my steep learning curve) The approach I have thought to use is to create an array holding the field name, the test and the message, then loop through using foreach, applying the array values into the test and creating the error message....but it's not working for me. The other method is to declare a variable $Stop='No' and if the loop identifies an error, part of the output is to change this to 'yes' and through that redirect to the error page. I'd really welcome your advice and tuition....cheers.. my code so far is... Code: [Select] $Stop='No'; $StaffPassCheck=sanitisealphanum($_POST['PasswordCheck']); $Errors[0]['value']= sanitisealphanum($_POST['FirstName']); $Errors[0]['message']='Please re-enter your name'; $Errors[0]['test']=($StaffFname=""); $Errors[1]['value']= sanitisealphanum($_POST['Surname']); $Errors[1]['message']='Please re-enter your surname'; $Errors[1]['test']=($StaffSname=""); $Errors[2]['value']= sanitisealphanum($_POST['Post']); $Errors[2]['message']='You must select an option'; $Errors[2]['test']=($StaffPost="Select Value"); $Errors[3]['value']= sanitisealphanum($_POST['Username']); $Errors[3]['message']='You must select an option'; $Errors[3]['test']=($StaffUser=""); $Errors[4]['value']= sanitisealphanum($_POST['Password']); $Errors[4]['message']='Please re-enter your password'; $Errors[4]['test']=($StaffPass=""); $Errors[5]['value']= sanitisealphanum($_POST['PasswordCheck']); $Errors[5]['message']='Sorry, your passwords do not match'; $Errors[5]['test']=($StaffPass===$StaffPassCheck); foreach ($Errors as $key => $Value){ if ( $Errors['test']=true ){ $Stop='Yes'; return $_SESSION[$key]=$Value['message']; } } if ($Stop='Yes'){ header('Location.test.php'); die(); }else{ header('Location.indexp.php'); } Code: [Select] <?php include 'config.php'; //include 'dbc.php'; ?> <?php function filter($data) { // <--line 6 $data = trim(htmlentities(strip_tags($data))); if (get_magic_quotes_gpc()) $data = stripslashes($data); $data = mysql_real_escape_string($data); return $data; } ?> <?php /******************* ACTIVATION BY FORM**************************/ if ($_POST['doReset']=='Reset') { $err = array(); $msg = array(); foreach($_POST as $key => $value) { $data[$key] = filter($value); } if(!isEmail($data['email'])) { $err[] = "ERROR - Please enter a valid email"; } $email = $data['email']; //check if activ code and user is valid as precaution $rs_check = mysql_query("select id from users where email='$email'") or die (mysql_error()); $num = mysql_num_rows($rs_check); // Match row found with more than 1 results - the user is authenticated. if ( $num <= 0 ) { $err[] = "Error - Sorry no such account exists or registered."; //header("Location: forgot.php?msg=$msg"); //exit(); } if(empty($err)) { $new_pass = GenPwd(); $pass_reset = MD5($new_pass); //$sha1_new = sha1($new); //set update sha1 of new password + salt $rs_activ = mysql_query("update users set pass='$pass_reset' WHERE email='$email'") or die(mysql_error()); $host = $_SERVER['HTTP_HOST']; $host_upper = strtoupper($host); //send email $message = "Here are your new password details ...\n User Email: $email \n Passwd: $new_pass \n Thank You Administrator $host_upper ______________________________________________________ THIS IS AN AUTOMATED RESPONSE. ***DO NOT RESPOND TO THIS EMAIL**** "; mail($email, "Reset Password", $message, "From: \"Member Registration\" <auto-reply@$host>\r\n" . "X-Mailer: PHP/" . phpversion()); $msg[] = "Your account password has been reset and a new password has been sent to your email address."; //$msg = urlencode(); //header("Location: forgot.php?msg=$msg"); //exit(); } } ?> <html> <head> <title>Forgot Password</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="JavaScript" type="text/javascript" src="js/jquery-1.3.2.min.js"></script> <script language="JavaScript" type="text/javascript" src="js/jquery.validate.js"></script> <script> $(document).ready(function(){ $("#actForm").validate(); }); </script> <link href="styles.css" rel="stylesheet" type="text/css"> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="5" class="main"> <tr> <td colspan="3"> </td> </tr> <tr> <td width="160" valign="top"><p> </p> <p> </p> <p> </p> <p> </p> <p> </p></td> <td width="732" valign="top"> <h3 class="titlehdr">Forgot Password</h3> <p> <?php /******************** ERROR MESSAGES************************************************* This code is to show error messages **************************************************************************/ if(!empty($err)) { echo "<div class=\"msg\">"; foreach ($err as $e) { echo "* $e <br>"; } echo "</div>"; } if(!empty($msg)) { echo "<div class=\"msg\">" . $msg[0] . "</div>"; } /******************************* END ********************************/ ?> </p> <p>If you have forgot the account password, you can <strong>reset password</strong> and a new password will be sent to your email address.</p> <form action="forgot.php" method="post" name="actForm" id="actForm" > <table width="65%" border="0" cellpadding="4" cellspacing="4" class="loginform"> <tr> <td colspan="2"> </td> </tr> <tr> <td width="36%">Your Email</td> <td width="64%"><input name="email" type="text" class="required email" id="txtboxn" size="25"></td> </tr> <tr> <td colspan="2"> <div align="center"> <p> <input name="doReset" type="submit" id="doLogin3" value="Reset"> </p> </div></td> </tr> </table> <div align="center"></div> <p align="center"> </p> </form> <p> </p> <p align="left"> </p></td> <td width="196" valign="top"> </td> </tr> <tr> <td colspan="3"> </td> </tr> </table> </body> </html> Fatal error: Cannot redeclare filter() (previously declared in/forgot.php:6) what is wrong ? Hi.. Im new to php.. This is my form validate code.. im getting errors...i did my best to do this code Can anyone help me and correct my code Code: [Select] <?php session_start(); // submit button clicked if(isset($_POST['submit'])){ $errors=array(); // Continue when clicked if(isset($_POST['Role'], $_POST['Name'], $_POST['datepicker'], $_POST['gender'], $_POST['activity'], $_POST['Address'], $_POST['Photo'], $_POST['Biodata'], $_POST['certificates'], $_POST['Salary'])){ // Fields are all set else error : No errors conintue // Set variables an sanitise $Emp_Save= mysql_real_escape_string($_POST['Emp_Save']); // Sanitise $Emp_Cancel=$_POST['Emp_Cancel']; // Sanitise $Role=$_POST['Role']; // Sanitise $Name=$_POST['Name']; // Sanitise $datepicker=$_POST['datepicker']; // Sanitise $gender=$_POST['gender']; // Sanitise $activity=$_POST['activity']; // Sanitise $Address=$_POST['Address']; // Sanitise $Photo=$_POST['Photo']; // Sanitise $Biodata=$_POST['Biodata']; // Sanitise $certificates=$_POST['certificates']; // Sanitise $Salary=$_POST['Salary']; // Sanitise //-- Continue with error checks ;; if($_Role == ""){ $errors[]='Please Select The Employee Role!'; } if(strlen($Name >30){ $errors[]='Name Is Too Long!'; } else if(empty($Name)) { $errors[]='Please Fill The Field!'; } // Vslidate Datepicker if(strlen($datepicker) != 10){ $errors[]='Date should only be 10 characters and number .'; } // explode datepaicker by what ever youre using to separate them $datepicker_ex = explode('/', $datepicker); // Check that theyre numbers if(!is_numeric($datepicker_ex[0]) || !is_numeric($datepicker_ex[1]) || !is_numeric($datepicker_ex[2])){ $errors[]='Date should only be number .'; } else { // they are number format them back and cast to int , just incase $datepicker = (int)$datepicker_ex[0].'/'.(int)$datepicker_ex[1].'/'.(int)$datepicker_ex[2]; } // END - date picker valiadation else if($gender == ""){ $errors[]='Please Select The Gender!'; } else if($Activity == ""){ $errors[]='Please Select the Status!'; } else if($Address == ""){ $errors[]='Please Enter The Address!'; if(array_key_exists('Photo', $_FILES)) { $allowed_filetypes = array('.jpg','.gif','.bmp','.png','.jpeg'); $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Validate the uploaded file if($_FILES['Photo']['size'] === 0 || empty($_FILES['Photo']['tmp_name'])) { echo("<p>No file was selected.</p>\r\n"); } else if($_FILES['Photo']['size'] > 50000) { echo("<p>The file was too large.</p>\r\n"); } else if($_FILES['Photo']['error'] !== UPLOAD_ERR_OK) { // There was a PHP error echo("<p>There was an error uploading.</p>\r\n"); // Check if the filetype is allowed, if not DIE and inform the user. if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); } if(array_key_exists('Biodata', $_FILES)) { $allowed_filetypes = array('.pdf'); $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Validate the uploaded file if($_FILES['Biodata']['size'] === 0 || empty($_FILES['Biodata']['tmp_name'])) { echo("<p>No file was selected.</p>\r\n"); } else if($_FILES['Biodata']['size'] > 50000) { echo("<p>The file was too large.</p>\r\n"); } else if($_FILES['Biodata']['error'] !== UPLOAD_ERR_OK) { // There was a PHP error echo("<p>There was an error uploading.</p>\r\n"); if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); } if(array_key_exists('certificates', $_FILES)) { $allowed_filetypes = array('.pdf'); $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Validate the uploaded file if($_FILES['certificates']['size'] === 0 || empty($_FILES['certificates']['tmp_name'])) { echo("<p>No file was selected.</p>\r\n"); } else if($_FILES['certificates']['size'] > 50000) { echo("<p>The file was too large.</p>\r\n"); } else if($_FILES['certificates']['error'] !== UPLOAD_ERR_OK) { // There was a PHP error echo("<p>There was an error uploading.</p>\r\n"); if(!in_array($ext,$allowed_filetypes)) die('The file you attempted to upload is not allowed.'); } elseif($_EmpSalary == ""){ $errors[]='Please Enter The Salary!'; } //----- End error checks do insert or display errors of any are found -- if(empty($errors)){ // do insert $query = mysql_query("INSERT INTO `formdetails` (role,name,,date_of_birth,gender,activity,address,photo,biodata,certificates,salary) VALUES ('$Role', '$Name','$datepicker',, '$gender','$activity','$Address','$Photo','$Biodata','$certificates','$_EmpSalary')"); } else { foreach($errors as $error){ // display errors echo $error; } } //--------------------------------------------------- } else { $errors[]= 'All fields required.'; } } // END -- ?> MOD EDIT: [code] . . . [/code] BBCode tags added. Hello to everyone! I'm complete new in PHP and have the next problem: Please correct the following error: Enter your name doesn't matter if the field(Your name:) is filled or not Code: [Select] <form method="post" action="send.php" id="recomendus"> <table style="width: 100%;" border="0" cellspacing="6px" cellpadding="0" align="center"> <tbody> <tr> <td width="1%"><span style="color: #ff0000;">*</span></td> <td width="39%">Email:</td> <td width="60%"><label> <input id="email" type="text" name="clentEmail" value="" /> </label></td> </tr> <tr> <td><span style="color: #ff0000;">*</span></td> <td>First Name:</td> <td><input id="clentFname" type="text" name="yourname" value="" /></td> </tr> <tr> <td><span style="color: #ff0000;">*</span></td> <td>Last Name:</td> <td><input id="clentLname" type="text" name="clentLname" value="" /></td> </tr> <tr> <td><span style="color: #ff0000;">*</span></td> <td>Country:</td> <td><select id="Country2" name="Country2"> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option> <option value="American Samoa">American Samoa</option> <option value="Andorra">Andorra</option> <option value="Angola">Angola</option> <option value="Anguilla">Anguilla</option> <option value="Antarctica">Antarctica</option> <option value="Antigua and Barbuda">Antigua and Barbuda</option> <option value="Argentina">Argentina</option> <option value="Armenia ">Armenia </option> <option value="Aruba">Aruba</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Azerbaijan">Azerbaijan</option> <option value="Bahamas">Bahamas</option> <option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option> <option value="Barbados">Barbados</option> <option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option> <option value="Belize">Belize</option> <option value="Benin">Benin</option> <option value="Bermuda ">Bermuda </option> <option value="Bhutan">Bhutan</option> <option value="Bolivia">Bolivia</option> <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option> <option value="Botswana">Botswana</option> <option value="Bouvet Island">Bouvet Island</option> <option value="Brazil">Brazil</option> <option value="British Indian Ocean Territory">British Indian Ocean Territory</option> <option value="Brunei Darussalam ">Brunei Darussalam </option> <option value="Bulgaria">Bulgaria</option> <option value="Burkina Faso">Burkina Faso</option> <option value="Burundi">Burundi</option> <option value="Cambodia">Cambodia</option> <option value="Cameroon">Cameroon</option> <option value="Canada">Canada</option> <option value="Cape Verde">Cape Verde</option> <option value="Cayman Islands">Cayman Islands</option> <option value="Central African Republic ">Central African Republic </option> <option value="Chad">Chad</option> <option value="Chile">Chile</option> <option value="China">China</option> <option value="Christmas Island">Christmas Island</option> <option value="Cocos Islands">Cocos Islands</option> <option value="Colombia">Colombia</option> <option value="Comoros">Comoros</option> <option value="Congo">Congo</option> <option value="Congo, Democratic Republic of the">Congo, Democratic Republic of the</option> <option value="Cook Islands ">Cook Islands </option> <option value="Costa Rica">Costa Rica</option> <option value="Cote d">Cote d'Ivoire</option> <option value="Croatia">Croatia</option> <option value="Cuba">Cuba</option> <option value="Cyprus">Cyprus</option> <option value="Czech Republic">Czech Republic</option> <option value="Denmark">Denmark</option> <option value="Djibouti">Djibouti</option> <option value="Dominica">Dominica</option> <option value="Dominican Republic">Dominican Republic</option> <option value="Ecuador ">Ecuador </option> <option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option> <option value="Equatorial Guinea">Equatorial Guinea</option> <option value="Eritrea">Eritrea</option> <option value="Estonia">Estonia</option> <option value="Ethiopia">Ethiopia</option> <option value="Falkland Islands">Falkland Islands</option> <option value="Faroe Islands">Faroe Islands</option> <option value="Fiji">Fiji</option> <option value="Finland">Finland</option> <option value="France ">France </option> <option value="French Guiana">French Guiana</option> <option value="French Polynesia">French Polynesia</option> <option value="Gabon">Gabon</option> <option value="Gambia">Gambia</option> <option value="Georgia">Georgia</option> <option value="Germany">Germany</option> <option value="Ghana">Ghana</option> <option value="Gibraltar">Gibraltar</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Grenada">Grenada</option> <option value="Guadeloupe ">Guadeloupe </option> <option value="Guam">Guam</option> <option value="Guatemala">Guatemala</option> <option value="Guinea">Guinea</option> <option value="Guinea-Bissau">Guinea-Bissau</option> <option value="Guyana">Guyana</option> <option value="Haiti">Haiti</option> <option value="Heard Island and McDonald Islands">Heard Island and McDonald Islands</option> <option value="Honduras">Honduras</option> <option value="Hong Kong">Hong Kong</option> <option value="Hungary ">Hungary </option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Indonesia">Indonesia</option> <option value="Iran">Iran</option> <option value="Iraq">Iraq</option> <option value="Ireland">Ireland</option> <option value="Israel">Israel</option> <option value="Italy">Italy</option> <option value="Jamaica">Jamaica</option> <option value="Japan">Japan</option> <option value="Jordan">Jordan</option> <option value="Kazakhstan">Kazakhstan</option> <option value="Kenya">Kenya</option> <option value="Kiribati">Kiribati</option> <option value="Kuwait">Kuwait</option> <option value="Kyrgyzstan ">Kyrgyzstan </option> <option value="Laos">Laos</option> <option value="Latvia">Latvia</option> <option value="Lebanon">Lebanon</option> <option value="Lesotho">Lesotho</option> <option value="Liberia">Liberia</option> <option value="Libya">Libya</option> <option value="Liechtenstein">Liechtenstein</option> <option value="Lithuania">Lithuania</option> <option value="Luxembourg">Luxembourg</option> <option value="Macao">Macao</option> <option value="Madagascar">Madagascar</option> <option value="Malawi">Malawi</option> <option value="Malaysia">Malaysia</option> <option value="Maldives ">Maldives </option> <option value="Mali">Mali</option> <option value="Malta">Malta</option> <option value="Marshall Islands">Marshall Islands</option> <option value="Martinique">Martinique</option> <option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option> <option value="Mayotte">Mayotte</option> <option value="Mexico">Mexico</option> <option value="Micronesia">Micronesia</option> <option value="Moldova">Moldova</option> <option value="Monaco">Monaco</option> <option value="Mongolia">Mongolia</option> <option value="Montenegro ">Montenegro </option> <option value="Montserrat">Montserrat</option> <option value="Morocco">Morocco</option> <option value="Mozambique">Mozambique</option> <option value="Myanmar">Myanmar</option> <option value="Namibia">Namibia</option> <option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option> <option value="Netherlands">Netherlands</option> <option value="Netherlands Antilles">Netherlands Antilles</option> <option value="New Caledonia">New Caledonia</option> <option value="New Zealand">New Zealand</option> <option value=" Nicaragua"> Nicaragua</option> <option value="Niger">Niger</option> <option value="Nigeria">Nigeria</option> <option value="Norfolk Island">Norfolk Island</option> <option value="North Korea">North Korea</option> <option value="Norway">Norway</option> <option value="Oman">Oman</option> <option value="Pakistan">Pakistan</option> <option value="Palau">Palau</option> <option value="Palestinian Territory">Palestinian Territory</option> <option value="Panama">Panama</option> <option value=" Papua New Guinea"> Papua New Guinea</option> <option value="Paraguay">Paraguay</option> <option value="Peru">Peru</option> <option value="Philippines">Philippines</option> <option value="Pitcairn">Pitcairn</option> <option value="Poland">Poland</option> <option value="Portugal">Portugal</option> <option value="Puerto Rico">Puerto Rico</option> <option value="Qatar">Qatar</option> <option value="Romania">Romania</option> <option value="Russian Federation">Russian Federation</option> <option value="Rwanda ">Rwanda </option> <option value="Saint Helena">Saint Helena</option> <option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option> <option value="Saint Lucia">Saint Lucia</option> <option value="Saint Pierre and Miquelon">Saint Pierre and Miquelon</option> <option value="Saint Vincent and the Grenadines">Saint Vincent and the Grenadines</option> <option value="Samoa ">Samoa </option> <option value="San Marino">San Marino</option> <option value="Sao Tome and Principe">Sao Tome and Principe</option> <option value="Saudi Arabia">Saudi Arabia</option> <option value="Senegal">Senegal</option> <option value="Serbia">Serbia</option> <option value="Seychelles">Seychelles</option> <option value="Sierra Leone">Sierra Leone</option> <option value="Singapore">Singapore</option> <option value="Slovakia">Slovakia</option> <option value="Slovenia ">Slovenia </option> <option value="Solomon Islands">Solomon Islands</option> <option value="Somalia">Somalia</option> <option value="South Africa">South Africa</option> <option value="South Georgia">South Georgia</option> <option value="South Korea">South Korea</option> <option value="Spain">Spain</option> <option value="Sri Lanka">Sri Lanka</option> <option value="Sudan">Sudan</option> <option value="Suriname">Suriname</option> <option value="Svalbard and Jan Mayen">Svalbard and Jan Mayen</option> <option value=" Swaziland"> Swaziland</option> <option value="Sweden">Sweden</option> <option value="Switzerland">Switzerland</option> <option value="Syrian Arab Republic">Syrian Arab Republic</option> <option value="Taiwan">Taiwan</option> <option value="Tajikistan">Tajikistan</option> <option value="Tanzania">Tanzania</option> <option value="Thailand">Thailand</option> <option value="The Former Yugoslav Republic of Macedonia ">The Former Yugoslav Republic of Macedonia </option> <option value="Timor-Leste">Timor-Leste</option> <option value="Togo">Togo</option> <option value="Tokelau">Tokelau</option> <option value="Tonga">Tonga</option> <option value="Trinidad and Tobago">Trinidad and Tobago</option> <option value="Tunisia">Tunisia</option> <option value="Turkey">Turkey</option> <option value="Turkmenistan">Turkmenistan</option> <option value="Tuvalu">Tuvalu</option> <option value="Uganda">Uganda</option> <option value="Ukraine">Ukraine</option> <option value="United Arab Emirates ">United Arab Emirates </option> <option selected="selected" value="United Kingdom">United Kingdom</option> <option value="United States">United States</option> <option value="United States Minor Outlying Islands">United States Minor Outlying Islands</option> <option value="Uruguay">Uruguay</option> <option value="Uzbekistan">Uzbekistan</option> <option value="Vanuatu">Vanuatu</option> <option value="Vatican City">Vatican City</option> <option value="Venezuela">Venezuela</option> <option value=" Vietnam"> Vietnam</option> <option value="Virgin Islands, British">Virgin Islands, British</option> <option value="Virgin Islands, U.S.">Virgin Islands, U.S.</option> <option value="Wallis and Futuna">Wallis and Futuna</option> <option value="Western Sahara">Western Sahara</option> <option value="Yemen">Yemen</option> <option value="Zambia">Zambia</option> <option value="Zimbabwe">Zimbabwe</option> </select></td> </tr> </tbody> </table> <p><strong>Friend Details</strong></p> <table style="width: 100%;" border="0" cellspacing="6px" cellpadding="0" align="center"> <tbody> <tr> <td width="1%"><span style="color: #ff0000;">*</span></td> <td width="39%">Email:</td> <td width="60%"><label> <input id="email2" type="text" name="email2" value="" /> </label></td> </tr> <tr> <td><span style="color: #ff0000;">*</span></td> <td>Title:</td> <td><label> <select id="Title" name="Title"> <option value="">[Select Title]</option> <option value="Mr.">Mr.</option> <option value="Mrs.">Mrs.</option> <option value="Miss.">Miss.</option> <option value="Ms.">Ms.</option> <option value="Dr.">Dr.</option> </select> </label></td> </tr> <tr> <td><span style="color: #ff0000;">*</span></td> <td>First Name:</td> <td><input id="FirstName" type="text" name="FirstName" value="" /></td> </tr> <tr> <td><span style="color: #ff0000;">*</span></td> <td>Last Name:</td> <td><input id="LastName" type="text" name="LastName" value="" /></td> </tr> <tr> <td><span style="color: #ff0000;">*</span></td> <td>Country:</td> <td><select id="Country" name="Country"> <option value="Albania">Albania</option> <option value="Algeria">Algeria</option> <option value="American Samoa">American Samoa</option> <option value="Andorra">Andorra</option> <option value="Angola">Angola</option> <option value="Anguilla">Anguilla</option> <option value="Antarctica">Antarctica</option> <option value="Antigua and Barbuda">Antigua and Barbuda</option> <option value="Argentina">Argentina</option> <option value="Armenia ">Armenia </option> <option value="Aruba">Aruba</option> <option value="Australia">Australia</option> <option value="Austria">Austria</option> <option value="Azerbaijan">Azerbaijan</option> <option value="Bahamas">Bahamas</option> <option value="Bahrain">Bahrain</option> <option value="Bangladesh">Bangladesh</option> <option value="Barbados">Barbados</option> <option value="Belarus">Belarus</option> <option value="Belgium">Belgium</option> <option value="Belize">Belize</option> <option value="Benin">Benin</option> <option value="Bermuda ">Bermuda </option> <option value="Bhutan">Bhutan</option> <option value="Bolivia">Bolivia</option> <option value="Bosnia and Herzegovina">Bosnia and Herzegovina</option> <option value="Botswana">Botswana</option> <option value="Bouvet Island">Bouvet Island</option> <option value="Brazil">Brazil</option> <option value="British Indian Ocean Territory">British Indian Ocean Territory</option> <option value="Brunei Darussalam ">Brunei Darussalam </option> <option value="Bulgaria">Bulgaria</option> <option value="Burkina Faso">Burkina Faso</option> <option value="Burundi">Burundi</option> <option value="Cambodia">Cambodia</option> <option value="Cameroon">Cameroon</option> <option value="Canada">Canada</option> <option value="Cape Verde">Cape Verde</option> <option value="Cayman Islands">Cayman Islands</option> <option value="Central African Republic ">Central African Republic </option> <option value="Chad">Chad</option> <option value="Chile">Chile</option> <option value="China">China</option> <option value="Christmas Island">Christmas Island</option> <option value="Cocos Islands">Cocos Islands</option> <option value="Colombia">Colombia</option> <option value="Comoros">Comoros</option> <option value="Congo">Congo</option> <option value="Congo, Democratic Republic of the">Congo, Democratic Republic of the</option> <option value="Cook Islands ">Cook Islands </option> <option value="Costa Rica">Costa Rica</option> <option value="Cote d">Cote d'Ivoire</option> <option value="Croatia">Croatia</option> <option value="Cuba">Cuba</option> <option value="Cyprus">Cyprus</option> <option value="Czech Republic">Czech Republic</option> <option value="Denmark">Denmark</option> <option value="Djibouti">Djibouti</option> <option value="Dominica">Dominica</option> <option value="Dominican Republic">Dominican Republic</option> <option value="Ecuador ">Ecuador </option> <option value="Egypt">Egypt</option> <option value="El Salvador">El Salvador</option> <option value="Equatorial Guinea">Equatorial Guinea</option> <option value="Eritrea">Eritrea</option> <option value="Estonia">Estonia</option> <option value="Ethiopia">Ethiopia</option> <option value="Falkland Islands">Falkland Islands</option> <option value="Faroe Islands">Faroe Islands</option> <option value="Fiji">Fiji</option> <option value="Finland">Finland</option> <option value="France ">France </option> <option value="French Guiana">French Guiana</option> <option value="French Polynesia">French Polynesia</option> <option value="Gabon">Gabon</option> <option value="Gambia">Gambia</option> <option value="Georgia">Georgia</option> <option value="Germany">Germany</option> <option value="Ghana">Ghana</option> <option value="Gibraltar">Gibraltar</option> <option value="Greece">Greece</option> <option value="Greenland">Greenland</option> <option value="Grenada">Grenada</option> <option value="Guadeloupe ">Guadeloupe </option> <option value="Guam">Guam</option> <option value="Guatemala">Guatemala</option> <option value="Guinea">Guinea</option> <option value="Guinea-Bissau">Guinea-Bissau</option> <option value="Guyana">Guyana</option> <option value="Haiti">Haiti</option> <option value="Heard Island and McDonald Islands">Heard Island and McDonald Islands</option> <option value="Honduras">Honduras</option> <option value="Hong Kong">Hong Kong</option> <option value="Hungary ">Hungary </option> <option value="Iceland">Iceland</option> <option value="India">India</option> <option value="Indonesia">Indonesia</option> <option value="Iran">Iran</option> <option value="Iraq">Iraq</option> <option value="Ireland">Ireland</option> <option value="Israel">Israel</option> <option value="Italy">Italy</option> <option value="Jamaica">Jamaica</option> <option value="Japan">Japan</option> <option value="Jordan">Jordan</option> <option value="Kazakhstan">Kazakhstan</option> <option value="Kenya">Kenya</option> <option value="Kiribati">Kiribati</option> <option value="Kuwait">Kuwait</option> <option value="Kyrgyzstan ">Kyrgyzstan </option> <option value="Laos">Laos</option> <option value="Latvia">Latvia</option> <option value="Lebanon">Lebanon</option> <option value="Lesotho">Lesotho</option> <option value="Liberia">Liberia</option> <option value="Libya">Libya</option> <option value="Liechtenstein">Liechtenstein</option> <option value="Lithuania">Lithuania</option> <option value="Luxembourg">Luxembourg</option> <option value="Macao">Macao</option> <option value="Madagascar">Madagascar</option> <option value="Malawi">Malawi</option> <option value="Malaysia">Malaysia</option> <option value="Maldives ">Maldives </option> <option value="Mali">Mali</option> <option value="Malta">Malta</option> <option value="Marshall Islands">Marshall Islands</option> <option value="Martinique">Martinique</option> <option value="Mauritania">Mauritania</option> <option value="Mauritius">Mauritius</option> <option value="Mayotte">Mayotte</option> <option value="Mexico">Mexico</option> <option value="Micronesia">Micronesia</option> <option value="Moldova">Moldova</option> <option value="Monaco">Monaco</option> <option value="Mongolia">Mongolia</option> <option value="Montenegro ">Montenegro </option> <option value="Montserrat">Montserrat</option> <option value="Morocco">Morocco</option> <option value="Mozambique">Mozambique</option> <option value="Myanmar">Myanmar</option> <option value="Namibia">Namibia</option> <option value="Nauru">Nauru</option> <option value="Nepal">Nepal</option> <option value="Netherlands">Netherlands</option> <option value="Netherlands Antilles">Netherlands Antilles</option> <option value="New Caledonia">New Caledonia</option> <option value="New Zealand">New Zealand</option> <option value=" Nicaragua"> Nicaragua</option> <option value="Niger">Niger</option> <option value="Nigeria">Nigeria</option> <option value="Norfolk Island">Norfolk Island</option> <option value="North Korea">North Korea</option> <option value="Norway">Norway</option> <option value="Oman">Oman</option> <option value="Pakistan">Pakistan</option> <option value="Palau">Palau</option> <option value="Palestinian Territory">Palestinian Territory</option> <option value="Panama">Panama</option> <option value=" Papua New Guinea"> Papua New Guinea</option> <option value="Paraguay">Paraguay</option> <option value="Peru">Peru</option> <option value="Philippines">Philippines</option> <option value="Pitcairn">Pitcairn</option> <option value="Poland">Poland</option> <option value="Portugal">Portugal</option> <option value="Puerto Rico">Puerto Rico</option> <option value="Qatar">Qatar</option> <option value="Romania">Romania</option> <option value="Russian Federation">Russian Federation</option> <option value="Rwanda ">Rwanda </option> <option value="Saint Helena">Saint Helena</option> <option value="Saint Kitts and Nevis">Saint Kitts and Nevis</option> <option value="Saint Lucia">Saint Lucia</option> <option value="Saint Pierre and Miquelon">Saint Pierre and Miquelon</option> <option value="Saint Vincent and the Grenadines">Saint Vincent and the Grenadines</option> <option value="Samoa ">Samoa </option> <option value="San Marino">San Marino</option> <option value="Sao Tome and Principe">Sao Tome and Principe</option> <option value="Saudi Arabia">Saudi Arabia</option> <option value="Senegal">Senegal</option> <option value="Serbia">Serbia</option> <option value="Seychelles">Seychelles</option> <option value="Sierra Leone">Sierra Leone</option> <option value="Singapore">Singapore</option> <option value="Slovakia">Slovakia</option> <option value="Slovenia ">Slovenia </option> <option value="Solomon Islands">Solomon Islands</option> <option value="Somalia">Somalia</option> <option value="South Africa">South Africa</option> <option value="South Georgia">South Georgia</option> <option value="South Korea">South Korea</option> <option value="Spain">Spain</option> <option value="Sri Lanka">Sri Lanka</option> <option value="Sudan">Sudan</option> <option value="Suriname">Suriname</option> <option value="Svalbard and Jan Mayen">Svalbard and Jan Mayen</option> <option value=" Swaziland"> Swaziland</option> <option value="Sweden">Sweden</option> <option value="Switzerland">Switzerland</option> <option value="Syrian Arab Republic">Syrian Arab Republic</option> <option value="Taiwan">Taiwan</option> <option value="Tajikistan">Tajikistan</option> <option value="Tanzania">Tanzania</option> <option value="Thailand">Thailand</option> <option value="The Former Yugoslav Republic of Macedonia ">The Former Yugoslav Republic of Macedonia </option> <option value="Timor-Leste">Timor-Leste</option> <option value="Togo">Togo</option> <option value="Tokelau">Tokelau</option> <option value="Tonga">Tonga</option> <option value="Trinidad and Tobago">Trinidad and Tobago</option> <option value="Tunisia">Tunisia</option> <option value="Turkey">Turkey</option> <option value="Turkmenistan">Turkmenistan</option> <option value="Tuvalu">Tuvalu</option> <option value="Uganda">Uganda</option> <option value="Ukraine">Ukraine</option> <option value="United Arab Emirates ">United Arab Emirates </option> <option selected="selected" value="United Kingdom">United Kingdom</option> <option value="United States">United States</option> <option value="United States Minor Outlying Islands">United States Minor Outlying Islands</option> <option value="Uruguay">Uruguay</option> <option value="Uzbekistan">Uzbekistan</option> <option value="Vanuatu">Vanuatu</option> <option value="Vatican City">Vatican City</option> <option value="Venezuela">Venezuela</option> <option value=" Vietnam"> Vietnam</option> <option value="Virgin Islands, British">Virgin Islands, British</option> <option value="Virgin Islands, U.S.">Virgin Islands, U.S.</option> <option value="Wallis and Futuna">Wallis and Futuna</option> <option value="Western Sahara">Western Sahara</option> <option value="Yemen">Yemen</option> <option value="Zambia">Zambia</option> <option value="Zimbabwe">Zimbabwe</option> </select></td> </tr> <tr> <td><span style="color: #ff0000;">*</span></td> <td>Telephone (Home):</td> <td><input id="telhome" type="text" name="telhome" value="" /></td> </tr> <tr> <td><span style="color: #ff0000;">*</span></td> <td>Telephone (Work):</td> <td><input id="telwork" type="text" name="telwork" value="" /></td> </tr> <tr> <td><span style="color: #ff0000;">*</span></td> <td>Telephone (Mobile):</td> <td><input id="telmobile" type="text" name="telmobile" value="" /></td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> <td> </td> <td><label> <input id="button" type="submit" name="button" value="Submit" /> </label></td> </tr> </tbody> </table> </form> <?php /* Set e-mail recipient */ $myemail = "myemail@gmail.com"; /* Check all form inputs using check_input function */ $clentEmail = check_input($_POST['clentEmail']); $yourname = check_input($_POST['clentFname'], "Enter your name"); $clentLname = check_input($_POST['clentLname'], "Enter your last name"); $lastname = check_input($_POST['lastname'], "Write your last name"); $Country2 = check_input($_POST['Country2'], "Your Country"); $email2 = check_input($_POST['email2'], "Enter your email"); $Title = check_input($_POST['Title']); $FirstName = check_input($_POST['FirstName'], "Enter your name222"); $LastName = check_input($_POST['LastName'], "Enter your last name"); $Country = check_input($_POST['Country'], "Your Country"); $telhome = check_input($_POST['telhome'], "Enter your home nomber"); $telwork = check_input($_POST['telwork'], "Enter your work nomber"); $telmobile = check_input($_POST['telmobile'], "Enter your mobile nomber"); /* If e-mail is not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) { show_error("E-mail address not valid"); } /* If URL is not valid set $website to empty */ if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website)) { $website = ''; } /* Let's prepare the message for the e-mail */ $message = "Hello! Your contact form has been submitted by: Client Name: $clentFname Client Last Name: $clentLname Client E-mail: $email Client Country: $Country2 Friend Detail: E-mail: $email2 Title: $Title First Name: $FirstName Last Name: $LastName Country: $Country Home Nomber: $telhome Work Nomber: $telwork Mobile Nomber: $telmobile End of message "; /* Send the message using mail() function */ mail($myemail, $subject, $message); /* Redirect visitor to the thank you page */ header('Location: '); exit(); /* Functions we used */ function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <html> <body> <b>Please correct the following error:</b><br /> <?php echo $myError; ?> </body> </html> <?php exit(); } ?> Hello.. I have two php form and one has categories and their subjects. In there, users can select category and relevant subjects to that category. Likewise users can select upto 3 categories and their subjects in first form. when those select and after submitting those should handle in my second page. But I have made so frustrated here when Im going to handle those in my second page. Please Can anybody help me to do this. I use this, but...... Code: [Select] if ( ( isset($_POST['submitted2'])) && ( isset($_SESSION['category'])) && (isset( $_SESSION['subjects'])) && sizeof( $_SESSION['category']) == 1) { //$_SESSION['category'] = $_POST['category']; print_r ( $_SESSION['category']); echo 'good'; } elseif ( ( isset($_POST['submitted2'])) && ( isset($_SESSION['category'])) && (isset( $_POST['main_category'] ))) { print_r ( $_SESSION ); echo 'very good'; } Thanks in advance. So I am trying to make an incorrect password message but the message never appears.
My code:
<? require "./includes/config.php"; $LS->init(); if(isset($_POST['act_login'])){ $user=$_POST['login']; $pass=$_POST['pass']; if($user=="" || $pass==""){ $msg=array("Error", "Username / Password Wrong !"); } else { if(!$LS->login($user, $pass)){ $msg=array("Error", "Username / Password Wrong !"); } } } ?> Hi, I'm quite a newbie to PHP and am doing a website. Have got a login working and the registration half way there, but am now in process of putting validation in Registration form. Have got the errors appearing if domething isn't filled in or if the username is taken however, it clears all the fields and i would like it to keep the values in them if possible. Is there an easy way round this? I can give my code if needed Cozzy I am a new developer, trying to figure out what causing a memory error. The code goes through registered appointments and depends on the service ID, I have to free a 45 minutes for another service to be booked. Now, once I book an appointment for any of the services that can have 45 minutes free spot, the website takes forever to load the hours but doesn't show them, instead I get this error A PHP Error was encountered Severity: Error Message: Maximum execution time of 120 seconds exceeded
foreach ($appointments as $appointment) { foreach ($periods as $index => &$period) { $appointment_start = new DateTime($appointment['start_datetime']); $appointment_end = new DateTime($appointment['end_datetime']); if ($appointment_start >= $appointment_end) { continue; } $period_start = new DateTime($date . ' ' . $period['start']); $period_end = new DateTime($date . ' ' . $period['end']); $serviceId=$appointment['id_services']; $color1=1; $color2=2; $color3=3; $color4=4; $color5=5; $color6=6; $color7=7; $color8=8; $color9=9; $color10=10; $color11=11; $color12=12; $color13=13; $color14=14; $color15=15; $color16=16; $color17=17; $color18=18; $color19=19; $period_s=''; $period_e=''; if ($appointment_start <= $period_start && $appointment_end <= $period_end && $appointment_end <= $period_start) { // The appointment does not belong in this time period, so we will not change anything. continue; } else { if ($appointment_start <= $period_start && $appointment_end <= $period_end && $appointment_end >= $period_start) { // The appointment starts before the period and finishes somewhere inside. We will need to break // this period and leave the available part. //open slot for services 45,45,45 if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // // //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['start'] = $appointment_end->format('H:i'); } // //for the rest of services else { $period['start'] = $appointment_end->format('H:i');} } else { if ($appointment_start >= $period_start && $appointment_end < $period_end) { // The appointment is inside the time period, so we will split the period into two new // others. unset($periods[$index]); if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // // //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } //for other services once The code is completely correct else{ $periods[] = [ 'start' => $period_start->format('H:i'), 'end' => $appointment_start->format('H:i') ]; $periods[] = [ 'start' => $appointment_end->format('H:i'), 'end' => $period_end->format('H:i') ]; } } else if ($appointment_start == $period_start && $appointment_end == $period_end) { if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ unset($periods[$index]); $period_s= $appointment_start; $period_s->modify('+45 minutes'); $period_e= $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} // //for the rest of services else { unset($periods[$index]);} // The whole period is blocked so remove it from the available periods array. } else { if ($appointment_start >= $period_start && $appointment_end >= $period_start && $appointment_start <= $period_end) { // The appointment starts in the period and finishes out of it. We will need to remove //the time that is taken from the appointment. if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $period['end'] = $appointment_start->format('H:i'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $period['end'] = $appointment_start->format('H:i'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['end'] = $appointment_start->format('H:i'); } // // //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['end'] = $appointment_start->format('H:i'); } // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['end'] = $appointment_start->format('H:i'); } // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; $period['end'] = $appointment_start->format('H:i'); } // for the rest of services else{ $period['end'] = $appointment_start->format('H:i'); } } else { if ($appointment_start >= $period_start && $appointment_end >= $period_end && $appointment_start >= $period_end) { // The appointment does not belong in the period so do not change anything. continue; } else { if ($appointment_start <= $period_start && $appointment_end >= $period_end && $appointment_start <= $period_end) { //Open slot for service 45,45,45 if($serviceId == $color1 || $serviceId == $color3 || $serviceId == $color7 || $serviceId == $color9|| $serviceId == $color10 || $serviceId == $color11 || $serviceId == $color12){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } //Open slot for service 45,45,60 else if($serviceId == $color2 || $serviceId == $color8){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+45 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ]; } // //Open slot for service 30,45,45 else if($serviceId == $color4 || $serviceId == $color6 ||$serviceId == $color16 || $serviceId == $color18){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} //Open slot for service 30,45,60 else if($serviceId == $color5 || $serviceId == $color17){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+30 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} // // //Open slot for service 60,45,45 else if($serviceId == $color13 || $serviceId == $color15){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-45 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} // // //Open slot for service 60,45,60 else if($serviceId == $color14 ){ unset($periods[$index]); $period_s= clone $appointment_start; $period_s->modify('+60 minutes'); $period_e= clone $appointment_end; $period_e->modify('-60 minutes'); $periods[] = [ 'start' => $period_s->format('H:i'), 'end' =>$period_e->format('H:i') ];} else{ unset($periods[$index]); } } } } } } } } } return array_values($periods); } Hello all,
Appreciate if you folks could pls. help me understand (and more importantly resolve) this very weird error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC, purchase_later_flag ASC, shopper1_buy_flag AS' at line 3' in /var/www/index.php:67 Stack trace: #0 /var/www/index.php(67): PDO->query('SELECT shoplist...') #1 {main} thrown in /var/www/index.php on line 67
Everything seems to work fine when/if I use the following SQL query (which can also be seen commented out in my code towards the end of this post) :
$sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id";However, the moment I change my query to the following, which essentially just includes/adds the ORDER BY clause, I receive the error quoted above: $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master ORDER BY purchased_flag ASC, purchase_later_flag ASC, shopper1_buy_flag ASC, shopper2_buy_flag ASC, store_name ASC) WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id";In googling for this error I came across posts that suggested using "ORDER BY FIND_IN_SET()" and "ORDER BY FIELD()"...both of which I tried with no success. Here's the portion of my code which seems to have a problem, and line # 67 is the 3rd from bottom (third last) statement in the code below: <?php /* $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id"; */ $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master ORDER BY FIND_IN_SET(purchased_flag ASC, purchase_later_flag ASC, shopper1_buy_flag ASC, shopper2_buy_flag ASC, store_name ASC) WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id"; $result = $pdo->query($sql); // foreach ($pdo->query($sql) as $row) { foreach ($result as $row) { echo '<tr>'; print '<td><span class="filler-checkbox"><input type="checkbox" name="IDnumber[]" value="' . $row["idnumber"] . '" /></span></td>';Thanks Been screwing around on Google for about 3 hours trying to find a tutorial on what I am trying to do with absolutely no luck! I am simply trying to get my test script to echo errors from an array when a form criteria does not validate. This is my final revision which is still not working! Can someone please tell me what I am doing wrong? No matter what I do, I can't get away from this error: Notice: Undefined variable: error in C:\wamp\www\php\form_validation.php on line 13 <?php $o = $error[]; // test echo $o; // test if(!preg_match('/[^0-9A-Za-z]/',$_POST['first_name'])) { $error[] = "Please enter a valid First Name"; ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> First Name:<br /> <input name="first_name" type="text" size="50" maxlength="50" /><br /><br /> <input type="submit" /><br /><br /> </form> Hello, I have a registration page requesting simple information (first name, last name, email and password). When I click my 'register' button I receive the following errors:
Below is most of the code where I experience issues. The lines called out a mysqli_stmt_bind_param($q, 'ssss', $first_name, $last_name, $email, $hashed_passcode); // execute query mysqli_stmt_execute($q); if (mysqli_stmt_affected_rows($q) == 1) { // One record inserted if (empty($errors)) { // If everything's OK. // Register the user in the database... // Hash password current 60 characters but can increase $hashed_passcode = password_hash($password1, PASSWORD_DEFAULT); require ('msqli_connect.php'); // Connect to the db. // Make the query: $query = "INSERT INTO users (userid, first_name, last_name, "; $query .= "email, password, registration_date) "; $query .="VALUES(' ', ?, ?, ?, ?, NOW() )"; $q = mysqli_stmt_init($dbcon); mysqli_stmt_prepare($q, $query); // use prepared statement to ensure that only text is inserted // bind fields to SQL Statement mysqli_stmt_bind_param($q, 'ssss', $first_name, $last_name, $email, $hashed_passcode); // execute query mysqli_stmt_execute($q); if (mysqli_stmt_affected_rows($q) == 1) { // One record inserted header ("location: register-thanks.php"); exit(); } else { // If it did not run OK. // Public message: $errorstring = "<p class='text-center col-sm-8' style='color:red'>"; $errorstring .= "System Error<br />You could not be registered due "; $errorstring .= "to a system error. We apologize for any inconvenience.</p>"; echo "<p class=' text-center col-sm-2' style='color:red'>$errorstring</p>"; // Debugging message below do not use in production //echo '<p>' . mysqli_error($dbcon) . '<br><br>Query: ' . $query . '</p>'; mysqli_close($dbcon); // Close the database connection. // include footer then close program to stop execution echo '<footer class="jumbotron text-center col-sm-12" style="padding-bottom:1px; padding-top:8px;"> include("footer.php"); </footer>'; exit(); } } else { // Report the errors. $errorstring = "Error! <br /> The following error(s) occurred:<br>"; foreach ($errors as $msg) { // Print each error. $errorstring .= " - $msg<br>\n"; } $errorstring .= "Please try again.<br>"; echo "<p class=' text-center col-sm-2' style='color:red'>$errorstring</p>"; }// End of if (empty($errors)) IF. } catch(Exception $e) // We finally handle any problems here { // print "An Exception occurred. Message: " . $e->getMessage(); print "The system is busy please try later"; } catch(Error $e) { //print "An Error occurred. Message: " . $e->getMessage(); print "The system is busy please try again later."; } ?> I have done some searching around to try and figure out the issue; but I can't seem to put my finger on it. This is a new database, and I haven't been able to get test registered as of yet. Any help would be appreciated. Thank you Hi, I have taken the step of writing my site in MySQLi instead of MYSQL as advised. However, I had a script that I got off the internet, the original file works great and registers the user to the database. However the edited version of the script, where I have added more information such as the users address etc, no longer works. I have compared the two files and can't seem to find the problem. When the script is run, it skips all the registration part and jumps to the last error in the script saying 'You Could Not Be Registered Because Of Missing Data.'. All the variables match the column names in the database.
Here is the original working script
<?php error_reporting(E_ALL); ini_set('display_errors', '1'); // some error checking /* if($_POST['reg']){ echo "form submitted"; }else{ echo "form not submitted"; } */ if( isset( $_POST['user'] ) && isset( $_POST['pass'] ) && isset( $_POST['email'] ) ){ // echo $_POST['user']." - ".$_POST['pass']." - ".$_POST['email']; if( strlen( $_POST['user'] ) < 5 ) { include('header.inc'); echo "Username Must Be 5 or More Characters."; include('footer.inc'); } elseif( strlen( $_POST['pass'] ) < 5 ) { include('header.inc'); echo "Password Must Be 5 or More Characters."; include('footer.inc'); } elseif( $_POST['pass'] == $_POST['user'] ) { include('header.inc'); echo "Username And Password Can Not Be The Same."; include('footer.inc'); } elseif( $_POST['email'] == "" ) { //More secure to use a regular expression to check that the user is entering a valid email // versus just checking to see if the field is empty include('header.inc'); echo "Email must be valid."; include('footer.inc'); } else { require( 'database.php' ); $username = mysqli_real_escape_string($con, $_POST['user']); //Remove md5() function if not using encryption i.e. $password = $_POST['pass']; $password = mysqli_real_escape_string($con, md5( $_POST['pass'])); $email = mysqli_real_escape_string($con, $_POST['email'] ); $sqlCheckForDuplicate = "SELECT username FROM user WHERE username = '". $username ."'"; //echo "$sqlCheckForDuplicate<br/>"; $result = mysqli_query($con, $sqlCheckForDuplicate); if(mysqli_num_rows($result) == 0){ //echo "No Duplicates<br/>"; $sqlRegUser = "INSERT INTO user( username, password, email ) VALUES ( '". $username ."', '". $password ."', '". $email."' )"; //echo "$sqlRegUser<br/>"; if( !mysqli_query($con, $sqlRegUser ) ) { include('header.inc'); echo "You Could Not Register Because Of An Unexpected Error."; include('footer.inc'); } else { /* Note: When using the header function, you cannot send output to the browser * before the header function is called. IF you want to echo a message to the * user before going back to your login page then you should use the HTML * Meta Refresh tag. */ //echo "You Are Registered And Can Now Login"; //echo " $username"; //this is for error checking header ('location: login.php'); // if using echo then use meta refresh /* *?> *<meta http-equiv="refresh" content="2;url= login.php/"> *<? */ } mysqli_free_result($result); } else { include('header.inc'); echo "The Username You Have Chosen Is Already Being Used By Another User. Please Try Another One."; //echo " $username;" //this is for error checking include('footer.inc'); } /* close connection */ mysqli_close($con); } } else { include('header.inc'); echo "You Could Not Be Registered Because Of Missing Data."; include('footer.inc'); } ?>and here is my version <?php error_reporting(E_ALL); ini_set('display_errors', '1'); if( isset( $_POST['user'] ) && isset( $_POST['pass'] ) && isset( $_POST['pass_again'] ) && isset( $_POST['firstname'] ) && isset( $_POST['lastname'] ) && isset( $_POST['email'] ) && isset( $_POST['email_again'] ) && isset( $_POST['address1'] ) && isset( $_POST['address2'] ) && isset( $_POST['town'] ) && isset( $_POST['county'] ) && isset( $_POST['postcode'] ) && isset( $_POST['business'] ) && isset( $_POST['vat_registered'] ) && isset( $_POST['vat_number'] )) { if( strlen( $_POST['user'] ) < 5 ) { include('includes/overall/header.php'); echo "Username Must Be 5 or More Characters."; include('includes/overall/footer.php'); } elseif( strlen( $_POST['pass'] ) < 5 ) { include('includes/overall/header.php'); echo "Password Must Be 5 or More Characters."; include('includes/overall/footer.php'); } elseif( $_POST['pass'] == $_POST['user'] ) { include('includes/overall/header.php'); echo "Username And Password Can Not Be The Same."; include('includes/overall/footer.php'); } elseif( $_POST['pass_again'] == "" ) { include('includes/overall/header.php'); echo "Passwords must match"; include('includes/overall/footer.php'); } // CREATE BETTER EMAIL CHECK elseif( $_POST['email'] == "" ) { include('includes/overall/header.php'); echo "Email must be valid."; include('includes/overall/footer.php'); } elseif( $_POST['email_again'] == "" ) { include('includes/overall/header.php'); echo "Emails must match."; include('includes/overall/footer.php'); } elseif( $_POST['address_1'] == "" ) { include('includes/overall/header.php'); echo "Address cannot be empty"; include('includes/overall/footer.php'); } elseif( $_POST['address_2'] == "" ) { include('includes/overall/header.php'); echo "Address cannot be empty"; include('includes/overall/footer.php'); } elseif( $_POST['town'] == "" ) { include('includes/overall/header.php'); echo "Town cannot be empty"; include('includes/overall/footer.php'); } elseif( $_POST['county'] == "" ) { include('includes/overall/header.php'); echo "County cannot be empty"; include('includes/overall/footer.php'); } elseif( $_POST['postcode'] == "" ) { include('includes/overall/header.php'); echo "Postcode cannot be empty"; include('includes/overall/footer.php'); } elseif( $_POST['business'] == "" ) { include('includes/overall/header.php'); echo "Business cannot be empty"; include('includes/overall/footer.php'); } elseif( $_POST['vat_registered'] == "" ) { include('includes/overall/header.php'); echo "VAT Registered cannot be empty"; include('includes/overall/footer.php'); } elseif( $_POST['vat_number'] == "" ) { include('includes/overall/header.php'); echo "VAT number cannot be empty, please enter N/A if not VAT registered."; include('includes/overall/footer.php'); } else { require( 'database.php' ); $username = mysqli_real_escape_string($con, $_POST['user']); //Remove md5() function if not using encryption i.e. $password = $_POST['pass']; $password = mysqli_real_escape_string($con, md5( $_POST['pass'])); $password_again = mysqli_real_escape_string($con, md5( $_POST['pass_again'])); $firstname = mysqli_real_escape_string($con, $_POST['firstname']); $lastname = mysqli_real_escape_string($con, $_POST['lastname']); $email = mysqli_real_escape_string($con, $_POST['email'] ); $email_again = mysqli_real_escape_string($con, $_POST['email_again']); $address_1 = mysqli_real_escape_string($con, $_POST['address_1']); $address_2 = mysqli_real_escape_string($con, $_POST['address_2']); $town = mysqli_real_escape_string($con, $_POST['town']); $county = mysqli_real_escape_string($con, $_POST['county']); $postcode = mysqli_real_escape_string($con, $_POST['postcode']); $business = mysqli_real_escape_string($con, $_POST['business']); $vat_registered = mysqli_real_escape_string($con, $_POST['vat_registered']); $vat_number = mysqli_real_escape_string($con, $_POST['vat_number']); $sqlCheckForDuplicate = "SELECT username FROM user WHERE username = '". $username ."'"; //echo "$sqlCheckForDuplicate<br/>"; $result = mysqli_query($con, $sqlCheckForDuplicate); if(mysqli_num_rows($result) == 0){ //echo "No Duplicates<br/>"; $sqlRegUser = "INSERT INTO user( username, password, password_again, firstname, lastname, email, email_again, address_1, address_2, town, county, postcode, business, vat_registered, vat_number ) VALUES ( '". $username ."', '". $password ."', '". $password_again ."', '". $firstname ."', '". $lastname ."', '". $email ."', '". $email_again ."', '". $address_1 ."', '". $address_2 ."', '". $town ."', '". $county ."', '". $postcode ."', '". $business ."', '". $vat_registered ."', '". $vat_number."' )"; //echo "$sqlRegUser<br/>"; if( !mysqli_query($con, $sqlRegUser ) ) { include('includes/overall/header.php'); echo "You Could Not Register Because Of An Unexpected Error."; include('includes/overall/footer.php'); } else { header ('location: login.php'); } mysqli_free_result($result); } else { include('includes/overall/header.php'); echo "The Username You Have Chosen Is Already Being Used By Another User. Please Try Another One."; //echo " $username;" //this is for error checking include('includes/overall/footer.php'); } /* close connection */ mysqli_close($con); } } else { include('includes/overall/header.php'); echo "You Could Not Be Registered Because Of Missing Data."; include('includes/overall/footer.php'); } ?> Error reporting is switched on, I just cant see the problem. Any help is much appreciated :) The error is on line 101. Help please. Code: [Select] <?php //begin register script $submit = $_POST['submit']; //form data $username= strip_tags ($_POST['username']); $email= strip_tags($_POST['email']); $pwd= strip_tags($_POST['pwd']); $confirmpwd= strip_tags($_POST['confirmpwd']); $date = date("Y-m-d"); if ($submit) { //check for required form data if($username&&$pwd&&$confirmpwd&&$email) { //encrypt password $pwd = md5($pwd); $confirmpwd =md5($pwd); //check if passwords match if ($pwd==$confirmpwd) { //check length of username if (strlen($username)>25||strlen($username)>25) { echo "length of username is too long"; } else { //check password length if(strlen($pwd)>25||strlen($pwd)<6) { echo"password must be between 6 and 25 characters"; } else { //register the user } else echo "your passwords do not match"; } else echo "please fill in all fields"; } ?> |