dimanche 2 octobre 2016

Form Values successfully storedto database, but won't execute if statement after

I'm having problems with my sign up form. Yes, it successfully stores information to my database but it just reloads the page(sign-up page) after and will not execute the code inside the if statement.This is my complete code(from the form and the php/mysql code):

        <form class="formoid-metro-black" id="close" style="background-color:transparent;font-size:14px;font-family:'Open Sans','Helvetica Neue','Helvetica',Arial,Verdana,sans-serif;color:#FFFFFF;max-width:480px;min-width:150px" method="post" enctype="multipart/form-data">

          <div class="title"><h2>Basic Information</h2></div>

          <div class="element-name"><label class="title"><span class="required">*</span></label><span class="nameFirst"><input  type="text" size="8" name="fname" required="required"/><label class="subtitle">First Name</label></span><span class="nameLast"><input  type="text" size="14" name="lname" required="required"/><label class="subtitle">Last Name</label></span></div>
          <div class="element-select"><label class="title">Gender<span class="required">*</span></label><div class="large"><span><select name="gender" required="required">

            <option value="Male" style="color:#000000">Male</option>
            <option value="Female" style="color:#000000">Female</option></select><i></i></span></div></div>
            <div class="element-date" style="color:#000000; background-color:transparent;"><label class="title" style="color:#fff;">Birthdate</label><input class="large" data-format="yyyy-mm-dd" type="date" name="bdate" placeholder="yyyy-mm-dd" style="color:#fff;"  /></div>
            <div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
            <div class="element-address"><label class="title">Address</label><span class="addr1"><input  type="text" name="street" /><label class="subtitle">Barangay / Street Address</label></span><span class="city"><input  type="text" name="city" /><label class="subtitle">City</label></span><span class="state"><input  type="text" name="province" /><label class="subtitle">Province / State</label></span><span class="zip"><input  type="text" maxlength="15" name="zcode" /><label class="subtitle">Zip Code</label></span><div class="country"><select name="country" ><!--<option selected="selected" value="" disabled="disabled">--- Select a country ---</option> --><option selected="selected" value="Philippines">Philippines</option><option style="color:#000000" value="United States">United States</option><option style="color:#000000" value="United Kingdom">United Kingdom</option><option style="color:#000000" value="Australia">Australia</option><option style="color:#000000" value="Canada">Canada</option><option style="color:#000000" value="France">France</option><option style="color:#000000" value="New Zealand">New Zealand</option><option style="color:#000000" value="India">India</option><option style="color:#000000" value="Brazil">Brazil</option><option style="color:#000000" value="----" disabled="disabled">----</option><option style="color:#000000" value="Afghanistan">Afghanistan</option><option style="color:#000000" value="Aland Islands">Aland Islands</option><option style="color:#000000" value="Albania">Albania</option><option style="color:#000000" value="Algeria">Algeria</option><option style="color:#000000" value="American Samoa">American Samoa</option><option style="color:#000000" value="Andorra">Andorra</option><option style="color:#000000" value="Angola">Angola</option><option style="color:#000000" value="Anguilla">Anguilla</option><option style="color:#000000" value="Antarctica">Antarctica</option><option style="color:#000000" value="Antigua and Barbuda">Antigua and Barbuda</option><option style="color:#000000" value="Argentina">Argentina</option><option style="color:#000000" value="Armenia">Armenia</option><option style="color:#000000" value="Aruba">Aruba</option><option style="color:#000000" value="Austria">Austria</option><option style="color:#000000" value="Azerbaijan">Azerbaijan</option><option style="color:#000000" value="Bahamas">Bahamas</option><option style="color:#000000" value="Bahrain">Bahrain</option><option style="color:#000000" value="Bangladesh">Bangladesh</option><option style="color:#000000" value="Barbados">Barbados</option><option style="color:#000000" value="Belarus">Belarus</option><option style="color:#000000" value="Belgium">Belgium</option><option style="color:#000000" value="Belize">Belize</option><option style="color:#000000" value="Benin">Benin</option><option style="color:#000000" value="Bermuda">Bermuda</option><option style="color:#000000" value="Bhutan">Bhutan</option><option style="color:#000000" value="Bolivia">Bolivia</option><option style="color:#000000" value="Bosnia and Herzegovina">Bosnia and Herzegovina</option><option style="color:#000000" value="Botswana">Botswana</option><option style="color:#000000" value="British Indian Ocean Territory">British Indian Ocean Territory</option><option style="color:#000000" value="Brunei Darussalam">Brunei Darussalam</option><option style="color:#000000" value="Bulgaria">Bulgaria</option><option style="color:#000000" value="Burkina Faso">Burkina Faso</option><option style="color:#000000" value="Burundi">Burundi</option><option style="color:#000000" value="Cambodia">Cambodia</option><option style="color:#000000" value="Cameroon">Cameroon</option><option style="color:#000000" value="Cape Verde">Cape Verde</option><option style="color:#000000" value="Cayman Islands">Cayman Islands</option><option style="color:#000000" value="Central African Republic">Central African Republic</option><option style="color:#000000" value="Chad">Chad</option><option style="color:#000000" value="Chile">Chile</option><option style="color:#000000" value="China">China</option><option style="color:#000000" value="Colombia">Colombia</option><option style="color:#000000" value="Comoros">Comoros</option><option style="color:#000000" value="Democratic Republic of the Congo">Democratic Republic of the Congo</option><option style="color:#000000" value="Republic of the Congo">Republic of the Congo</option><option style="color:#000000" value="Cook Islands">Cook Islands</option><option style="color:#000000" value="Costa Rica">Costa Rica</option><option style="color:#000000" value="Cote d'Ivoire">Cote d'Ivoire</option><option style="color:#000000" value="Croatia">Croatia</option><option style="color:#000000" value="Cuba">Cuba</option><option style="color:#000000" value="Cyprus">Cyprus</option><option style="color:#000000" value="Czech Republic">Czech Republic</option><option style="color:#000000" value="Denmark">Denmark</option><option style="color:#000000" value="Djibouti">Djibouti</option><option style="color:#000000" value="Dominica">Dominica</option><option style="color:#000000" value="Dominican Republic">Dominican Republic</option><option style="color:#000000" value="East Timor">East Timor</option><option style="color:#000000" value="Ecuador">Ecuador</option><option style="color:#000000" value="Egypt">Egypt</option><option style="color:#000000" value="El Salvador">El Salvador</option><option style="color:#000000" value="Equatorial Guinea">Equatorial Guinea</option><option style="color:#000000" value="Eritrea">Eritrea</option><option style="color:#000000" value="Estonia">Estonia</option><option style="color:#000000" value="Ethiopia">Ethiopia</option><option style="color:#000000" value="Faroe Islands">Faroe Islands</option><option style="color:#000000" value="Fiji">Fiji</option><option style="color:#000000" value="Finland">Finland</option><option style="color:#000000" value="Gabon">Gabon</option><option style="color:#000000" value="Gambia">Gambia</option><option style="color:#000000" value="Georgia">Georgia</option><option style="color:#000000" value="Germany">Germany</option><option style="color:#000000" value="Ghana">Ghana</option><option style="color:#000000" value="Gibraltar">Gibraltar</option><option style="color:#000000" value="Greece">Greece</option><option style="color:#000000" value="Grenada">Grenada</option><option style="color:#000000" value="Guatemala">Guatemala</option><option style="color:#000000" value="Guinea">Guinea</option><option style="color:#000000" value="Guinea-Bissau">Guinea-Bissau</option><option style="color:#000000" value="Guyana">Guyana</option><option style="color:#000000" value="Haiti">Haiti</option><option style="color:#000000" value="Honduras">Honduras</option><option style="color:#000000" value="Hong Kong">Hong Kong</option><option style="color:#000000" value="Hungary">Hungary</option><option style="color:#000000" value="Iceland">Iceland</option><option style="color:#000000" value="Indonesia">Indonesia</option><option style="color:#000000" value="Iran">Iran</option><option style="color:#000000" value="Iraq">Iraq</option><option style="color:#000000" value="Ireland">Ireland</option><option style="color:#000000" value="Israel">Israel</option><option style="color:#000000" value="Italy">Italy</option><option style="color:#000000" value="Jamaica">Jamaica</option><option style="color:#000000" value="Japan">Japan</option><option style="color:#000000" value="Jordan">Jordan</option><option style="color:#000000" value="Kazakhstan">Kazakhstan</option><option style="color:#000000" value="Kenya">Kenya</option><option style="color:#000000" value="Kiribati">Kiribati</option><option style="color:#000000" value="North Korea">North Korea</option><option style="color:#000000" value="South Korea">South Korea</option><option style="color:#000000" value="Kuwait">Kuwait</option><option style="color:#000000" value="Kyrgyzstan">Kyrgyzstan</option><option style="color:#000000" value="Laos">Laos</option><option style="color:#000000" value="Latvia">Latvia</option><option style="color:#000000" value="Lebanon">Lebanon</option><option style="color:#000000" value="Lesotho">Lesotho</option><option style="color:#000000" value="Liberia">Liberia</option><option style="color:#000000" value="Libya">Libya</option><option style="color:#000000" value="Liechtenstein">Liechtenstein</option><option style="color:#000000" value="Lithuania">Lithuania</option><option style="color:#000000" value="Luxembourg">Luxembourg</option><option style="color:#000000" value="Macedonia">Macedonia</option><option style="color:#000000" value="Madagascar">Madagascar</option><option style="color:#000000" value="Malawi">Malawi</option><option style="color:#000000" value="Malaysia">Malaysia</option><option style="color:#000000" value="Maldives">Maldives</option><option style="color:#000000" value="Mali">Mali</option><option style="color:#000000" value="Malta">Malta</option><option style="color:#000000" value="Marshall Islands">Marshall Islands</option><option style="color:#000000" value="Mauritania">Mauritania</option><option style="color:#000000" value="Mauritius">Mauritius</option><option style="color:#000000" value="Mexico">Mexico</option><option style="color:#000000" value="Micronesia">Micronesia</option><option style="color:#000000" value="Moldova">Moldova</option><option style="color:#000000" value="Monaco">Monaco</option><option style="color:#000000" value="Mongolia">Mongolia</option><option style="color:#000000" value="Montenegro">Montenegro</option><option style="color:#000000" value="Morocco">Morocco</option><option style="color:#000000" value="Mozambique">Mozambique</option><option style="color:#000000" value="Myanmar">Myanmar</option><option style="color:#000000" value="Namibia">Namibia</option><option style="color:#000000" value="Nauru">Nauru</option><option style="color:#000000" value="Nepal">Nepal</option><option style="color:#000000" value="Netherlands">Netherlands</option><option style="color:#000000" value="Netherlands Antilles">Netherlands Antilles</option><option style="color:#000000" value="Nicaragua">Nicaragua</option><option style="color:#000000" value="Niger">Niger</option><option style="color:#000000" value="Nigeria">Nigeria</option><option style="color:#000000" value="Norway">Norway</option><option style="color:#000000" value="Oman">Oman</option><option style="color:#000000" value="Pakistan">Pakistan</option><option style="color:#000000" value="Palau">Palau</option><option style="color:#000000" value="Palestine">Palestine</option><option style="color:#000000" value="Panama">Panama</option><option style="color:#000000" value="Papua New Guinea">Papua New Guinea</option><option style="color:#000000" value="Paraguay">Paraguay</option><option style="color:#000000" value="Peru">Peru</option><option style="color:#000000" value="Poland">Poland</option><option style="color:#000000" value="Portugal">Portugal</option><option style="color:#000000" value="Puerto Rico">Puerto Rico</option><option style="color:#000000" value="Qatar">Qatar</option><option style="color:#000000" value="Romania">Romania</option><option style="color:#000000" value="Russia">Russia</option><option style="color:#000000" value="Rwanda">Rwanda</option><option style="color:#000000" value="Saint Kitts and Nevis">Saint Kitts and Nevis</option><option style="color:#000000" value="Saint Lucia">Saint Lucia</option><option style="color:#000000" value="Saint Vincent and the Grenadines">Saint Vincent and the Grenadines</option><option style="color:#000000" value="Samoa">Samoa</option><option style="color:#000000" value="San Marino">San Marino</option><option style="color:#000000" value="Sao Tome and Principe">Sao Tome and Principe</option><option style="color:#000000" value="Saudi Arabia">Saudi Arabia</option><option style="color:#000000" value="Senegal">Senegal</option><option style="color:#000000" value="Serbia">Serbia</option><option style="color:#000000" value="Seychelles">Seychelles</option><option style="color:#000000" value="Sierra Leone">Sierra Leone</option><option style="color:#000000" value="Singapore">Singapore</option><option style="color:#000000" value="Slovakia">Slovakia</option><option style="color:#000000" value="Slovenia">Slovenia</option><option style="color:#000000" value="Solomon Islands">Solomon Islands</option><option style="color:#000000" value="Somalia">Somalia</option><option style="color:#000000" value="South Africa">South Africa</option><option style="color:#000000" value="Spain">Spain</option><option style="color:#000000" value="Sri Lanka">Sri Lanka</option><option style="color:#000000" value="Sudan">Sudan</option><option style="color:#000000" value="Suriname">Suriname</option><option style="color:#000000" value="Swaziland">Swaziland</option><option style="color:#000000" value="Sweden">Sweden</option><option style="color:#000000" value="Switzerland">Switzerland</option><option style="color:#000000" value="Syria">Syria</option><option style="color:#000000" value="Taiwan">Taiwan</option><option style="color:#000000" value="Tajikistan">Tajikistan</option><option style="color:#000000" value="Tanzania">Tanzania</option><option style="color:#000000" value="Thailand">Thailand</option><option style="color:#000000" value="Togo">Togo</option><option style="color:#000000" value="Tonga">Tonga</option><option style="color:#000000" value="Trinidad and Tobago">Trinidad and Tobago</option><option style="color:#000000" value="Tunisia">Tunisia</option><option style="color:#000000" value="Turkey">Turkey</option><option style="color:#000000" value="Turkmenistan">Turkmenistan</option><option style="color:#000000" value="Tuvalu">Tuvalu</option><option style="color:#000000" value="Uganda">Uganda</option><option style="color:#000000" value="Ukraine">Ukraine</option><option style="color:#000000" value="United Arab Emirates">United Arab Emirates</option><option style="color:#000000" value="United States Minor Outlying Islands">United States Minor Outlying Islands</option><option style="color:#000000" value="Uruguay">Uruguay</option><option style="color:#000000" value="Uzbekistan">Uzbekistan</option><option style="color:#000000" value="Vanuatu">Vanuatu</option><option style="color:#000000" value="Vatican City">Vatican City</option><option style="color:#000000" value="Venezuela">Venezuela</option><option style="color:#000000" value="Vietnam">Vietnam</option><option style="color:#000000" value="Virgin Islands, British">Virgin Islands, British</option><option style="color:#000000" value="Virgin Islands, U.S.">Virgin Islands, U.S.</option><option style="color:#000000" value="Yemen">Yemen</option><option style="color:#000000" value="Zambia">Zambia</option><option style="color:#000000" value="Zimbabwe">Zimbabwe</option></select><i></i><label class="subtitle">Country</label></div></div>
            <div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
            <div class="title"><h2>Log-in Information</h2></div>
            <div class="element-email"><label class="title">E-mail<span class="required">*</span></label><input class="large" type="email" name="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" value="" required="required"/></div>
            <div class="element-input"><label class="title">Username<span class="required">*</span></label><input class="large" type="text" name="username" required="required"/></div>
            <div class="element-password"><label class="title">Password<span class="required">*</span></label><input class="large" type="password" name="password" id="password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).{8,}" value="" required="required"/><label class="subtitle">Password must be at least 8 characters composed of at least 1 uppercase, 1 number and  letters. </label></div>
            <div class="element-password"><label class="title">Confirm Password<span class="required">*</span></label><input class="large" type="password" name="password1" id="confirm_password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).{8,}" value="" required="required"/></div>
            <div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
            <div class="element-phone"><label class="title">Phone<span class="required">*</span></label><input class="large" type="tel" pattern="[+]?[#0-9]{3,}" maxlength="14" name="phone" required="required" value=""/></div>
            <div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
            <div class="title"><h2>Profile Information</h2></div>
            <div class="element-file"><label class="title">Profile Picture</label><label class="large" ><div class="button">Choose Photo</div><input type="file" name="profilephoto" class="file_input" value="" /><div class="file_text">...</div></label></div>
            <div class="element-input"><label class="title">School</label><input class="large" type="text" name="school" value=""/><label class="subtitle">Name of last school graduated.</label></div>
            <div class="element-input"><label class="title">Work</label><input class="large" type="text" name="work" value=""/></div>
            <div class="submit"><input type="submit" name="submit" value="Sign Up"/></div></form><script type="text/javascript" src="forms/sign-up-form_files/formoid1/formoid-metro-black.js"></script>

            <?php include("includes/db-connect.php");


            if(isset($_POST['submit'])){
              $fname = $_POST['fname'];
              $lname = $_POST['lname'];                  
              $gender = $_POST['gender'];
              $bdate = $_POST['bdate'];
              $street = $_POST['street'];
              $city = $_POST['city'];
              $province = $_POST['province'];
              $zcode = $_POST['zcode'];
              $country = $_POST['country'];  

              $email = $_POST['email'];
              $username = $_POST['username'];
              $password = $_POST['password'];
              $password1 = $_POST['password1'];
              $phone = $_POST['phone'];

              $school = $_POST['school'];
              $work = $_POST['work'];

              $profilephoto = $_FILES['profilephoto']['name'];
              $photo_tmp = $_FILES['profilephoto']['tmp_name'];



              move_uploaded_file($photo_tmp,"includes/user/profile/$profilephoto");

              $userquery = "insert into user (`user-firstname`, `user-lastname`, `user-address`, `user-address-city`, `user-address-province`, `user-address-zipcode`, `user-email`, `user-username`, `user-password`, `user-phone`, `user-gender`, `user-address-country`, `user-birthdate`, `user-profile-photo`, `user-school`,`user-work`) values ('$fname', '$lname', '$street', '$city', '$province', '$zcode', '$email', '$username', '$password', '$phone', '$gender', '$country', '$bdate', '$profilephoto', '$school', '$work')";
              $dt = \DateTime::createFromFormat('m/d/Y', $_POST['bdate']);


              if (mysqli_query($conn, $userquery)) {
                ?><div id='openModal' class='modalDialog'><div><a href='log-in.php' title='Close' class='close'>X</a> <h3>Thank you! You have successfully registered.</h3></div></div>      

                <?php
              } else {
                ?><div id='openModal' class='modalDialog'><div><a href='../sign-up.php' title='Close' class='close'>X</a><h3>Error. Please try again.</h3><?php $userquery . mysqli_error($conn)?></div></div><?php ;
              }



              mysqli_close($conn);
            }

            ?>

What I want the code to execute after inserting the values if the code inside this if statement: if (mysqli_query($conn, $userquery)) {

Aucun commentaire:

Enregistrer un commentaire