register form issues

General discussion on PHP
Post Reply
will5247
Posts: 18
Joined: Sun Jun 01, 2014 4:38 am

register form issues

Post by will5247 » Sun Nov 29, 2015 10:59 pm

I have created a local php project and having issues trying to get the info sent to the database I get no error

php code


<?php include "includes/db.php"; ?>

<?php


if(isset($_POST['submit'])) {

$email = $_POST['email'];
$soldier_name = $_POST['soldier_name'];
$birthdate = $_POST['birthdate'];
$country = $_POST['country'];


if(!empty($email) && !empty($soldier_name) && !empty($birthdate) && !empty($country)) {



$email = mysqli_real_escape_string($connection, $email);
$soldier_name = mysqli_real_escape_string($connection, $soldier_name);
$birthdate = mysqli_real_escape_string($connection, $birthdate);
$country = mysqli_real_escape_string($connection, $country);


$query = "INSERT INTO soldiers (soldier_email, soldier, soldier_birthdate, soldier_country) ";
$query = "VALUES('{$email}','{$soldier_name}', '{$birthdate}', '{$country}' )";
$registration_query = mysqli_query($connection, $query);
if(!$registration_query) {
die("QUERY FAILED ". mysqli_error($connection) . ' ' . mysqli_errno($connection));
}


$message = "Your Registration has been submitted";



} else {


$message = "Fields cannot be empty";
}

} else {


$message = "";

}

?>


form code

<form role="form" action="create.php" method="post">
<div class="form-group">
<label>Email address</label>
<input class="form-control" type="email" id="email" name="email">
</div>
<div class="form-group">
<label>Confirm Email</label>
<input class="form-control" type="email" id="email_confirmation" name="email_confirmation">
</div>
<div class="form-group">
<label>Soldier Name</label>
<input class="form-control" type="text" id="soldier_name" name="soldier_name">
</div>
<div class="form-group">
<label>Birthdate</label>
<input class="form-control" type="text" id="birthdate" name="birthdate">
</div>
<div class="form-group">
<label>Country</label>
<select class="form-control" id="country" name="country">
<option selected value="">Please select your country</option>
<option value="1">Afghanistan</option>
<option value="2">Albania</option>
<option value="3">Algeria</option>
<option value="4">American samoa</option>
<option value="5">Andorra</option>
<option value="6">Antarctica</option>
<option value="7">Argentina</option>
<option value="8">Armenia</option>
<option value="9">Aruba</option>
<option value="10">Australia</option>
<option value="11">Austria</option>
<option value="12">Bahamas</option>
<option value="13">Barbados</option>
<option value="14">Belgium</option>
<option value="15">Bermuda</option>
<option value="16">Bolivia</option>
<option value="17">Bosnia</option>
<option value="18">Brazil</option>
<option value="20">Cambodia</option>
<option value="21">Canada</option>
<option value="22">Cayman Islands</option>
<option value="23">Chile</option>
<option value="24">China</option>
<option value="25">Colombia</option>
<option value="26">Costa Rica</option>
<option value="27">Cuba</option>
<option value="28">Czech Republic</option>
<option value="29">Denmark</option>
<option value="30">Dominica</option>
<option value="31">Dominican Republic</option>
<option value="32">Ecuador</option>
<option value="33">Egypt</option>
<option value="34">El Salvador</option>
<option value="35">England</option>
<option value="36">Europe</option>
<option value="37">Finland</option>
<option value="38">France</option>
<option value="39">Georgia</option>
<option value="40">Germany</option>
<option value="41">Gibraltar</option>
<option value="42">Greece</option>
<option value="43">Greenland</option>
<option value="44">Hong Kong</option>
<option value="45">Hungary</option>
<option value="46">Iceland</option>
<option value="47">India</option>
<option value="48">Iran</option>
<option value="49">Iraq</option>
<option value="50">Ireland</option>
<option value="51">Israel</option>
<option value="52">Italy</option>
<option value="53">Jamaica</option>
<option value="54">Japan</option>
<option value="55">Jordan</option>
<option value="56">Kenya</option>
<option value="57">Kuwait</option>
<option value="58">Lebanon</option>
<option value="59">Liberia</option>
<option value="60">Libya</option>
<option value="61">Malaysia</option>
<option value="62">Mexico</option>
<option value="63">Morocco</option>
<option value="64">Netherlands</option>
<option value="65">New Zealand</option>
<option value="66">Nigeria</option>
<option value="67">Norway</option>
<option value="68">Pakistan</option>
<option value="69">Palestine</option>
<option value="70">Panama</option>
<option value="71">Peru</option>
<option value="72">Poland</option>
<option value="73">Portugal</option>
<option value="74">Puerto Rico</option>
<option value="75">Qatar</option>
<option value="76">Romania</option>
<option value="77">Russia</option>
<option value="78">Saudi arabia</option>
<option value="79">Scotland</option>
<option value="80">Slovakia</option>
<option value="81">Slovenia</option>
<option value="82">Somalia</option>
<option value="83">South Africa</option>
<option value="84">South Georgia</option>
<option value="85">Spain</option>
<option value="86">Sudan</option>
<option value="87">Swaziland</option>
<option value="88">Sweden</option>
<option value="89">Switzerland</option>
<option value="90">Syria</option>
<option value="91">Taiwan</option>
<option value="92">Thailand</option>
<option value="93">Trinidad</option>
<option value="94">Turkey</option>
<option value="95">Ukraine</option>
<option value="96">United Arab Emirates</option>
<option value="97">United Kingdom</option>
<option value="98">United States</option>
<option value="99">Virgin Islands (British)</option>
<option value="100">Virgin Islands (U.S.)</option>
</select>
</div>
<input type="submit" name="submit" id="btn-login" class="btn btn-custom btn-lg btn-block" value="Register">
</form>

Post Reply