JezK
Edit File: addProfessional.php
<?php include("header.php"); if(!isset($_SESSION['add_profession']) && $_SESSION['signup_type']!=1){ echo "<script>window.location='dashboard.php'</script>"; } $countrycodes=$videocon->countries('dial_code',$recentPractCountry); $countrynames=$videocon->countries('name'); $categories=$videocon->categories(); if(isset($_POST['action']) && $_POST['action']=='addprofessional') { $addprofessional=$videocon->addProfessional($_POST,$_FILES); $showmsg=''; if($addprofessional!=1) { $countryID = $_POST['country']; $state = $videocon->getStates($countryID); $stateid = ''; if(isset($_POST['state']) && $_POST['state']!=''){ $stateid=$_POST['state']; } $stavalues = ''; foreach($state as $k=>$v) { $selected=""; if($v['id']==$stateid){ $selected="Selected"; } $stavalues.="<option value='".$v['id']."' ".$selected.">".$v['name']."</option>"; } $cityid=''; if(isset($_POST['city']) && $_POST['city']!=''){ $cityid=$_POST['city']; } $countryID = $_POST['state']; $cities = $videocon->getCities($countryID); $cityValues=""; foreach($cities as $k=>$v) { $selected=""; if($v['id']==$cityid){ $selected="Selected"; } $cityValues.="<option value='".$v['id']."' ".$selected.">".$v['name']."</option>"; } if($addprofessional==-1){ $showmsg ='Given email already existed';} elseif($addprofessional==-2){ $showmsg ='Given mobile already existed';} elseif($addprofessional==-3){ $showmsg ='Given business name already existed ';} elseif($addprofessional==-4){ $showmsg ='Given username already existed username';} elseif($addprofessional==-5){ $showmsg ='File upload is failured';} elseif($addprofessional==0){ $showmsg ='Profession account creation failed';} echo "<script>alert('".$showmsg."');</script>"; }else{ echo "<script>alert('Professional account created successfully.');window.location='professionalMng.php';</script>"; } } $country=$videocon->getCountry2($recentPractCountryID); ?> <section class="dashboard-counts section-padding"> <div class="container-fluid bg-white px-5 py-3"> <div class="row bg-white"> <div class="container text-dark"> <form action="" method="POST" enctype="multipart/form-data"> <div class="row justify-content-center align-items-center"> <div class="mb-4"> <img id="profileImage" src="img/slide.jpg" width="150px" height="150px" alt="your image" class="uploadImg"><br> <label for="profilePicture" class="btn btn-primary browsePic">Browse Photo</label> <input type="file" id="profilePicture" name="profilePicture" class="d-none" accept="image/jpg,image/jpeg, image/png" > </div> </div> <div class="row"> <div class="col-12 col-sm-8 col-md-8 col-lg-6 col-xl-6"> <!--<div class="form-group"> <label for="businessName" class="fieldName">Business Name</label> <input type="text" class="form-control formField-control" name="businessName" id="businessName"> </div>--> <div class="form-group"> <label for="profession" class="fieldName">Professional Name</label> <input type="text" class="form-control formField-control" name="professionalname" id="professionalname" value="<?php if(isset($_POST['professionalname']) && $_POST['professionalname']!=''){ echo $_POST['professionalname']; }?>"> </div> <div class="form-group"> <label for="profession" class="fieldName">Profession </label> <input type="text" class="form-control formField-control" name="profession" id="profession" value="<?php if(isset($_POST['profession']) && $_POST['profession']!=''){ echo $_POST['profession']; }?>"> </div> <div class="form-group"> <label for="categories" class="fieldName">Categories</label> <div> <select name="categories" id="categories" class="form-control formField-control filterby" style="background-color:#E8F2F6 !important"> <option value="">Select Category</option> <?php foreach($categories as $k=>$v){ ?> <option value="<?php echo $v['id'];?>" <?php if(isset($_POST['categories']) && $_POST['categories']==$v['id']){ echo "selected";}?> ><?php echo $v['name'];?></option> <?php } ?> </select> </div> </div> <div class="form-group"> <label for="specialization" class="fieldName">Specialization</label> <input type="text" class="form-control formField-control" name="specialization" id="specialization" value="<?php if(isset($_POST['specialization']) && $_POST['specialization']!=''){ echo $_POST['specialization']; }?>"> </div> <input id="tmpProfileImage" name="tmpProfileImage" type="hidden" value="<?php echo isset($_POST['tmpProfileImage'])?$_POST['tmpProfileImage']:''; ?>"> <div class="form-group"> <label for="country" class="fieldName">Country</label> <div> <select name="country" id="country" class="form-control formField-control filterby countries" style="background-color:#E8F2F6 !important"> <option value="">Select Country</option> <?php foreach($country as $k=>$v){ ?> <option value="<?php echo $v['id'];?>" <?php if(isset($_POST['country']) && $_POST['country']==$v['id']){ echo "selected";}?> ><?php echo $v['name'];?></option> <?php } ?> </select> </div> </div> <div class="form-group"> <label for="state" class="fieldName">State</label> <div> <select name="state" id="state" class="form-control formField-control filterby states" style="background-color:#E8F2F6 !important"> <option value="">Select State</option> <?php echo $stavalues; ?> </select> </div> </div> <div class="form-group"> <label for="categories" class="fieldName">City</label> <div> <select name="city" id="cities" class="form-control formField-control filterby" style="background-color:#E8F2F6 !important"> <option value="">Select City</option> <?php echo $cityValues; ?> </select> </div> </div> </div> <div class="col-12 col-sm-8 col-md-8 col-lg-6 col-xl-6"> <!-- <div class="form-group"> <label for="country" class="fieldName">Country</label> <select name="country" id="country" class="form-control formField-control"> <?php foreach($countrynames as $k=>$v){ $selectedval=''; if(isset($_POST['country']) && $_POST['country']!='' && $_POST['country']==$v['id']) { $selectedval="selected"; } echo "<option value='".$v['id']."' ".$selectedval.">".$v['name']."</option>"; } ?> </select> </div> --> <div class="form-group"> <label for="email" class="fieldName">Email ID</label> <input type="text" class="form-control formField-control" name="email" id="email" value="<?php if(isset($_POST['email']) && $_POST['email']!=''){ echo $_POST['email']; }?>"> </div> <div class="form-group"> <label for="mobile" class="fieldName">Mobile Number</label> <select name="country_code" id="country_code" class="countryCode-p filterby"> <?php foreach($countrycodes as $k=>$v){ $selectedval=''; if(isset($_POST['country_code']) && $_POST['country_code']!='' && $_POST['country_code']==str_replace('+','', $v['dial_code'])) { $selectedval="selected"; } echo "<option value='".str_replace('+','', $v['dial_code'])."' ".$selectedval.">".$v['dial_code']."</option>"; } ?> </select> <input type="tel" class="form-control formField-control mobilenoLeftalign" name="mobile" id="mobile" maxlength="15" autocomplete="off" autofocus value="<?php if(isset($_POST['mobile']) && $_POST['mobile']!=''){ echo $_POST['mobile']; }?>" /> </div> <div class="form-group d-none"> <label for="location" class="fieldName">Location</label> <input type="text" class="form-control formField-control" name="location" id="location" value="<?php if(isset($_POST['location']) && $_POST['location']!=''){ echo $_POST['location']; }?>"> </div> <div class="form-group"> <label for="username" class="fieldName">Username</label> <input type="text" class="form-control formField-control" name="username" id="username" value="<?php if(isset($_POST['username']) && $_POST['username']!=''){ echo $_POST['username']; }?>"> </div> <div class="form-group"> <label for="password" class="fieldName">Password</label> <div> <input id="password" type="password" class="form-control formField-control pwd" name="password" value="<?php if(isset($_POST['password']) && $_POST['password']!=''){ echo $_POST['password']; }?>" onpaste="return false" > <span toggle="#password" class="showHide field-icon toggle-password fieldName-forgot" id="show">Show</span> </div> </div> <div class="form-group"> <label for="owner" class="fieldName">About</label> <textarea type="textarea" class="form-control formField-control" name="about" id="about" value=""><?php echo isset($_POST["about"])?$_POST["about"]:""; ?></textarea> </div> <input type="hidden" name="action" id="action" value="addprofessional"> <div class="form-group mt-2 pt-1"> <label></label> <button class="btn basic-btn-color w-100" onclick="return addbusiness();">Register</button> </div> </div> </div> </form> </div> </div> </div> <!-- </div> --> </section> <?php include("mainFooter.php");?> <script> function readURL(input,id) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function(e) { $('#'+id).attr('src', e.target.result); } reader.readAsDataURL(input.files[0]); } } $("#profilePicture").change(function() { $('#profileImage').attr('src', 'img/slide.jpg'); readURL(this, 'profileImage'); }); $("#backgroundPicture").change(function() { readURL(this, 'backgroundImage'); }); </script> <!-- <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> --> <script src="js/jquery-1.12.4.min.js"></script> <script> $(document).ready(function(){ if($.trim($("#tmpProfileImage").val()) == "") { $('#profileImage').attr('src', 'img/slide.jpg'); } else { $("#profileImage").attr('src',$("#tmpProfileImage").val()) } $(".countries").on('change',function(){ var selectedCountry = $(".countries option:selected").val(); if(selectedCountry!='') { $.ajax({ type: "POST", url: "ajax.php", data: "mode=" + "country" + "&countryID=" + selectedCountry, success:function(data){ $('#state').html(''); $('#cities').html('<option value="">Select City</option>'); $('#state').append(data); } }); }else{ $('#state').html('<option value="">Select State</option>'); $('#cities').html('<option value="">Select City</option>'); } }); }); $(document).ready(function(){ $(".states").on('change',function(){ var selectedState = $(".states option:selected").val(); $.ajax({ type: "POST", url: "ajax.php", data: "mode=" + "state" + "&stateID=" + selectedState, success:function(data){ $('#cities').html(''); $('#cities').append(data); } }); }); }); <?php if(isset($_POST['country']) && $_POST['country']!=''){ ?> var selectedCountry = $(".countries option:selected").val(); if(selectedCountry!='') { $.ajax({ type: "POST", url: "ajax.php", data: "mode=" + "country" + "&countryID=" + selectedCountry +"&stateID=<?php echo $_POST['state'];?>", success:function(data){ $('#state').html(''); $('#cities').html('<option value="">Select City</option>'); $('#state').append(data); } }); }else{ $('#state').html('<option value="">Select State</option>'); $('#cities').html('<option value="">Select City</option>'); } <?php }?> <?php if(isset($_POST['state']) && $_POST['state']!=''){ ?> var selectedState = $(".states option:selected").val(); $.ajax({ type: "POST", url: "ajax.php", data: "mode=" + "state" + "&stateID=" + selectedState+"&cityID=<?php echo $_POST['city'];?>", success:function(data){ $('#cities').html(''); $('#cities').append(data); } }); <?php }?> </script> <script> var input = document.querySelector("#phone"), output = document.querySelector("#output"); var iti = window.intlTelInput(input, { nationalMode: true, separateDialCode: true, utilsScript: "build/js/utils.js" // just for formatting/placeholders etc }); var handleChange = function() { var text = (iti.isValidNumber()) ? "International: " + iti.getNumber() : "Please enter a number below"; var textNode = document.createTextNode(text); output.innerHTML = ""; output.appendChild(textNode); }; // listen to "keyup", but also "change" to update when the user selects a country input.addEventListener('change', handleChange); input.addEventListener('keyup', handleChange); </script>