html - Errors while submitting the form ( php & bootstrap) -
i'm intern @ company right now, , i've create registration , login form website.
currently i'm facing problem registration.
i declared in tutorials still getting these errors , can't figure out it.
this php script:
<?php //connection database include('connection.php'); if ($_server['request_method']=='post'){ //validation username $errors = array(); if(empty($_post['user_name'])){ $errors['user_name'] = 'please fill in username';//username }else{ $user_name = mysqli_real_escape_string($con, trim($_post['user_name'])); //validation check if username posted in use. if($check = $connection->query("select * student username = '$user_name'")){ if($check->num_rows){ $errors['user_name'] = 'username in use'; } }else{ $errors['user_name'] = 'the query did not work'; } } //validation password if(empty($_post['pword'])){ $errors['pword'] = 'please fill in password'; }else{ $pword = $_post['pword']; } //checking if password ented in verify password matching password field if(empty($_post['pwordconfirm'])){ $errors['pwordconfirm'] = 'please verify password'; }else{ $pwordconfirm = $_post['pwordconfirm']; if($pword!=$pwordconfirm){ $errors ['pwordconfirm'] = 'passwords not match'; }else{ $password = mysqli_real_escape_string($connection,trim($_post['pword'])); // $password = sha1($password); } } // validation name textfield if(empty($_post['fname'])){ $errors['fname'] = 'please fill in name '; }else{ $fname = mysqli_real_escape_string($connection,trim($_post['customer_name'])); } // validation passport textfield if(empty($_post['passport'])){ $errors['passport'] = 'please fill in passport '; }else{ $passport = mysqli_real_escape_string($connection,trim($_post['passport'])); } //validation email if(empty($_post['email'])){ $errors['email'] = 'please fill in email'; }else{ $email = mysqli_real_escape_string($connection,trim($_post['email'])); if($check = $connection->query("select * customer email = '$email'")){ if($check->num_rows){ $errors['email'] = 'email in use'; } }else{ $errors['email'] = 'the query did not work'; } } //validation phone no if(empty($_post['mobinput'])){ $errors['mobinput'] = 'please fill in phone'; }else{ $mobinput = mysqli_real_escape_string($connection,trim($_post['mobinput'])); } //validation phone no if(empty($_post['homemobinput'])){ $errors['homemobinput'] = 'please fill in phone'; }else{ $homemobinput = mysqli_real_escape_string($connection,trim($_post['homemobinput'])); } //validation phone no if(empty($_post['dob'])){ $errors['dob'] = 'please fill in phone'; }else{ $dob = mysqli_real_escape_string($connection,trim($_post['dob'])); } //validation gender column selected. if(empty($_post['sex'])){ $errors['sex'] = 'please fill in gender'; }else{ if( $_post['sex'] == 'default') { $errors['sex'] = 'please select gender'; } else{ $gender = mysqli_real_escape_string($connection,trim($_post['sex'])); } } //validation mstatus if(empty($_post['mstatus'])){ $errors['mstatus'] = 'please fill in phone'; }else{ $mstatus = mysqli_real_escape_string($connection,trim($_post['mstatus'])); } //validation education if(empty($_post['education'])){ $errors['education'] = 'please fill in phone'; }else{ $education = mysqli_real_escape_string($connection,trim($_post['education'])); } //validation occupation if(empty($_post['occupation'])){ $errors['occupation'] = 'please fill in phone'; }else{ $occupation = mysqli_real_escape_string($connection,trim($_post['occupation'])); } //validation address if(empty($_post['address'])){ $errors['address'] = 'please fill in address'; }else{ $address = mysqli_real_escape_string($connection,trim($_post['address'])); } //validation wmcauin if(empty($_post['wmcauin'])){ $errors['wmcauin'] = 'please fill in phone'; }else{ $wmcauin = mysqli_real_escape_string($connection,trim($_post['wmcauin'])); } //validation tp if(empty($_post['tp'])){ $errors['tp'] = 'please fill in phone'; }else{ $tp = mysqli_real_escape_string($connection,trim($_post['tp'])); } //validation wauinmassage if(empty($_post['wauinmassage'])){ $errors['wauinmassage'] = 'please fill in phone'; }else{ $wauinmassage = mysqli_real_escape_string($connection,trim($_post['wauinmassage'])); } //validation hduhabttbc if(empty($_post['hduhabttbc'])){ $errors['hduhabttbc'] = 'please fill in phone'; }else{ $hduhabttbc = mysqli_real_escape_string($connection,trim($_post['hduhabttbc'])); } if(empty($errors)){ $query = "insert student "; $query .= "(`student_id`, `full_name`, `adress`, `ic_passport_no`, `date_of_birth`, `mobile_no`, `home_no`, `email`, `marital_status`, `occupation`, `education`, `why_interest_in_massage`, `how_did_you_know_about_us`, `registration_date`, `traner_preference`, `course_of_interest`, `gender`, `username`, `password`, `user_type`) "; $query .= "values ('','$fname','$address','$sex','$passport','$dob','$mobinput','$homemobinput', '$email', '$mstatus', '$occupation', '$education', '$wauinmassage','$hduhabttbc', '', '$tp', '$wmcauin','$sex', '$user_name', '$password', 's' )"; $register = $connection->query($query); $customer_id = $connection->query("select customer_id customer email = '$email' , user_name = '$user_name'")->fetch_object()->customer_id; $query1 = "insert cart "; $query1 .= "(customer_id) "; $query1 .= "values ('customer_id')"; $addcart = $connection->query($query1); if(!$register && !addcart){ echo $query; } else { $message = 'registration completed, can login'; } }}?>
this html form:
<!-- popup registration form --> <div id="signup" class="modal fade" role="dialog"> <div class="modal-dialog"> <!-- popup registration form content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">massage course registration form</h4> </div> <div class="modal-body"> <form method="post" class="form-signin form-group"> <label for="usernameinput" class="usernameinput">username</label> <input type="text" class="form-control" id="user_name" name="user_name"> <br> <label for="passwordinput">password</label> <input type="password" class="form-control" id="passwordinput" name="pword"> <br> <br> <label for="nameinput">name</label> <input type="text" class="form-control" id="inputname" placeholder="jane doe" name="fname"> <br> <label for="icinput">i.c/passport no.</label> <input type="text" class="form-control" id="icinput" name="passport"> <br> <label for="emailinput">email</label> <input type="email" class="form-control" id="emailinput" placeholder="jane.doe@example.com" name="email"> <br> <label for="mobinput">mobile no</label> <input type="number_format" class="form-control" id="mobinput" name="mobinput"> <br> <label for="homemobinput">home no</label> <input type="number_format" class="form-control" id="homemobinput" name="homemobinput"> <br> <label for="dobinput">date of birth</label> <input type="date" class="form-control" id="dobinput" name="dob"> <br> <label for="sexinput">sex</label> <select class="form-control" id="sexinput" name="sex"> <option>male</option> <option>female</option> </select> <br> <label for="maritalstatusinput">marital status</label> <select class="form-control" id="maritalstatusinput" name="mstatus"> <option>single</option> <option>married</option> <option>divorced</option> <option>widowed</option> </select> <br> <label for="educationinput">education</label> <input type="text" class="form-control" id="educationinput" name="education"> <br> <label for="occupationinput">occupation</label> <input type="text" class="form-control" id="occupationinput" name="occupation"> <br> <label for="addressinput">address</label> <input type="text" class="form-control" id="addressinput" name="address"> <br> <label for="courseselection">which massage course interested in?</label> <select class="form-control selectpicker" id="courseselection" name="wmcauin"> <optgroup label="professional"> <option>full body massage</option> <option>reflexology course</option> <option>aromatherapy course</option> </optgroup> <optgroup label="advanced"> <option>pre , post natal</option> <option>slimming massage</option> <option>lymphatic drainage</option> <option>spa , facial</option> <option> raindrop techniques</option> <option>male health</option> <option>sport injury</option> <option>traditional malay</option> </optgroup> </select> <br> <label for="trainerpreferenceinput">trainer preference</label> <select class="form-control" id="trainerpreferenceinput" name="tp"> <option>male trainer</option> <option>female trainer</option> </select> <br> <label for="interestfeedbackinput">why interedted in massage?</label> <input type="text" class="form-control" id="interestfeedback" name="wauinmassage"> <br> <label for="referalfeedbackinput">how did heard tim bodycare training centre</label> <input type="text" class="form-control" id="referalfeedbackinput" name="hduhabttbc"> <div class="form-group"> <button type="submit" class="btn btn-primary" name="btn-signup"> <i class="glyphicon glyphicon-open-file"></i> sign </button> </div> </form> <div class="modal-footer"> <p>by clicking submit, agreeing our terms , conditions</p> </div> </div> </div> </div> <!-- end of popup registration form -->
note php script , html form in 1 file.
change variable name in training_index.php
$conn , $connection $conn
because in connection.php file mentioned db connection variable name
$con = new mysqli($servername, $username, $password, $dbname);
Comments
Post a Comment