ok so, the problem is it goes straight to the register3.php and it totally ignores the if statements! here is the code:

<html>
<head>
<link rel=stylesheet type=text/css href=style.css>
<title>Register</title>
</head>
<body>
<center>
<h1>You Are Now Ready To Register!</h1>
<div class=indexboxlarge>
<form action=" " method="post" name="register">
  <label>First Name*<br>
  <input name="name1" type="text" id="name1" value="">
  </label>
  <p>
    <label>Surname*<br>
    <input name="name2" type="text" id="name2">
    </label>
  </p>
<p>
    <label>Password*<br>
    <input name="pass" type="password" id="pass">
    </label>
  </p> 
<p>
    <label>Re-type password*<br>
    <input name="passconf" type="password" id="passconf">
    </label>
  </p> 
<p>
    <label>Birthday<br>
    <input name="birthday" type="text" id="birthday">
    </label>
  </p>
<label>Age<br>
 																	 <p>
 																	   <select name="age" id="age">
 																	     
 																	     <option value="5">5</option>
 																	         <option value="6">6</option>
 																	     <option value="7">7</option>
 																	     <option value="8">8</option>
 																	     <option value="9">9</option>
 																	     <option value="11">10</option>
 																	     <option value="11">11</option>
 																	     <option value="12">12</option>
 																	     <option value="13">13</option>
 																	     <option value="14">14</option>
 																	     <option value="15">15</option>
 																	     <option value="16">16</option>
 																	     <option value="17">17</option>
 																	     <option value="18">18</option>
 																	     <option value="19">19</option>
 																	     <option value="20">20</option>
 																	     <option value="21">21</option>
 																	     <option value="22">22</option>
 																	     <option value="23">23</option>
 																	     <option value="24">24</option>
 																	     <option value="25">25</option>
 																	     <option value="26">26</option>
 																	     <option value="27">27</option>
 																	     <option value="28">28</option>
 																	     <option value="29">29</option>
 																	     <option value="30">30</option>
 																	     <option value="31">31</option>
 																	     <option value="32">32</option>
 																	     <option value="33">33</option>
 																	     <option value="34">34</option>
 																	     <option value="35">35</option>
 																	     <option value="36">36</option>
 																	     <option value="37">37</option>
 																	     <option value="38">38</option>
 																	     <option value="39">39</option>
 																	     <option value="40">40</option>
 																	     <option value="41">41</option>
 																	     <option value="42">42</option>
 																	     <option value="43">43</option>
 																	     <option value="44">44</option>
 																	     <option value="45">45</option>
 																	     <option value="46">46</option>
 																	     <option value="47">47</option>
 																	     <option value="48">48</option>
 																	     <option value="49">49</option>
 																	     <option value="50">50</option>
 																	     <option value="51">51</option>
 																	     <option value="52">52</option>
 																	     <option value="53">53</option>
 																	     <option value="54">54</option>
 																	     <option value="55">55</option>
 																	     <option value="56">56</option>
 																	     <option value="57">57</option>
 																	     <option value="58">58</option>
 																	     <option value="59">59</option>
 																	     <option value="60">60</option>
 																	     <option value="61">61</option>
 																	     <option value="62">62</option>
 																	     <option value="63">63</option>
 																	     <option value="64">64</option>
 																	     <option value="65">65</option>
 																	     <option value="66">66</option>
 																	     <option value="67">67</option>
 																	     <option value="68">68</option>
 																	     <option value="69">69</option>
 																	     <option value="70">70</option>
 																	     <option value="71">71</option>
 																	     <option value="72">72</option>
 																	     <option value="73">73</option>
 																	     <option value="74">74</option>
 																	     <option value="75">75</option>
 																	     <option value="76">76</option>
 																	     <option value="77">77</option>
 																	     <option value="78">78</option>
 																	     <option value="79">79</option>
 																	     <option value="80">80</option>
 																	     <option value="81">81</option>
 																	     <option value="82">82</option>
 																	     <option value="83">83</option>
 																	     <option value="84">84</option>
 																	     <option value="85">85</option>
 																	     <option value="86">86</option>
 																	     <option value="87">87</option>
 																	     <option value="88">88</option>
 																	     <option value="89">89</option>
 																	     <option value="90">90</option>
 																	     <option value="91">91</option>
 																	     <option value="92">92</option>
 																	     <option value="93">93</option>
 																	     <option value="94">94</option>
 																	     <option value="95">95</option>
 																	     <option value="96">96</option>
 																	     <option value="97">97</option>
 																	     <option value="98">98</option>
 																	     <option value="99">99</option>
 																	     <option value="100">100</option>
																       </select>
</label>
</p>

 																	 <p>
 																	   <label>Home Phone Number<br>
 																	   <input name="homephonenumber" type="text" id="homephonenumber">
 																	   </label>
  </p>
 																	 <p>
 																	   <label>Mobile Phone Number<br>
 																	   <input name="mobilephonenumber" type="text" id="mobilephonenumber">
 																	   </label>
  </p>
 																	 <p>
 																	   <label>Work Phone Number<br>
 																	   <input name="workphonenumber" type="text" id="workphonenumber">
 																	   </label>
  </p>
 																	 <p>
 																	   <label>Address<br>
 																	   <textarea name="address" id="address"></textarea>
 																	   </label>
 																	 </p>
 																	 <p>
 																	   <label>Email<br>
 																	   <input name="email" type="text" id="email">
 																	   </label>
 																	 </p>
 																	 <p>
 																	   <label>About You
<br> 																	   
<textarea name="about" cols="40" rows="15" id="about"></textarea>
 																	   </label>
</p>
 																	 <p>
 																	   <label>
 																	   <input type="submit" name="Submit" value="Register">
 																	   </label>
 																	 </p>
</form>
<h2>* Required</h2>
</div>
</center>
<center>
<div class=errorbox>
<?php
$name1 = $_POST['name1'];
$name2 = $_POST['name2'];
$pass = $_POST['pass'];
$passconf = $_POST['passconf'];
$birthday = $_POST['birthday'];
$age = $_POST['age'];
$homephone = $_POST['homephonenumber'];
$mobilephone = $_POST['mobilephonenumber'];
$workphone = $_POST['workphonenumber'];
$address = $_POST['address'];
$email = $_POST['email'];
$about = $_POST['about'];
$username = $name1 ."." .$name2;
if ($pass != $passconf) {

echo "<center>";
echo "<b>Error:</b> Your passwords do not match.";
echo "<br>";
echo "</center>";

}


if ($pass == NULL) {

echo "<center>";
echo "<b>Error:</b> You must fill in your password.";
echo "<br>";
echo "</center>";

}

if ($passconf == NULL) {

echo "<center>";
echo "<b>Error:</b> You must re-type your password.";
echo "<br>";
echo "</center>";

}

if ($name1 == NULL) {

echo "<center>";
echo "<b>Error:</b> You must fill in your first name.";
echo "<br>";
echo "</center>";

}

if ($name2 == NULL) {

echo "<center>";
echo "<b>Error:</b> You must fill in your surname.";
echo "<br>";
echo "</center>";
$true = "true";
}
if ($true == "true")  {
include ("dbcon.php");
dbcon();
mysql_query("INSERT INTO user_info 
(username, 1_name, 2_name, birthday, age, home_phone, work_phone, mobile_phone, website, about, address, email, password) VALUES('$username','$name1', '$name2','$birthday', '$age', '$homephone', '$workphone', '$mobilephone', '$website', '$about', '$address', '$email', '$pass'  ) ") 
or die(mysql_error());  
header('location: register3.php');
}
?>
</div>
</center>



</body>
</html>
Member Avatar for diafol

You just gotta have a go yourself man. You spend more time posting to this forum asking for help than trying to debug your code.

Just isolate your code into chunks and pass some hard-coded values into key areas of your logic. Echo your variables at key areas to keep track of them. Echo out branches of your if statements, like "first if", "second if" etc.

I think the problem is that you are setting $true="true" in the last check. Just after that you are checking if this is true and inserting a record.
Try this code:

<?php
if(isset($_POST['submit'])){

$name1 = $_POST['name1'];
$name2 = $_POST['name2'];
$pass = $_POST['pass'];
$passconf = $_POST['passconf'];
$birthday = $_POST['birthday'];
$age = $_POST['age'];
$homephone = $_POST['homephonenumber'];
$mobilephone = $_POST['mobilephonenumber'];
$workphone = $_POST['workphonenumber'];
$address = $_POST['address'];
$email = $_POST['email'];
$about = $_POST['about'];
$username = $name1 ."." .$name2;

$true= "true"; //set to true by default
if ($pass != $passconf) {

echo "<center>";
echo "<b>Error:</b> Your passwords do not match.";
echo "<br>";
echo "</center>";
$true= "false";
}


if ($pass == NULL) {
$true= "false";
echo "<center>";
echo "<b>Error:</b> You must fill in your password.";
echo "<br>";
echo "</center>";
}

if ($passconf == NULL) {
$true= "false";
echo "<center>";
echo "<b>Error:</b> You must re-type your password.";
echo "<br>";
echo "</center>";
}

if ($name1 == NULL) {
$true= "false";
echo "<center>";
echo "<b>Error:</b> You must fill in your first name.";
echo "<br>";
echo "</center>";
}

if ($name2 == NULL) {
$true= "false";
echo "<center>";
echo "<b>Error:</b> You must fill in your surname.";
echo "<br>";
echo "</center>";
}
if ($true == "true")  {
include ("dbcon.php");
dbcon();
mysql_query("INSERT INTO user_info
(username, 1_name, 2_name, birthday, age, home_phone, work_phone, mobile_phone, website, about, address, email, password) VALUES('$username','$name1', '$name2','$birthday',
'$age', '$homephone', '$workphone', '$mobilephone', '$website', '$about', '$address', '$email', '$pass'  ) ")
or die(mysql_error());
header('location: register3.php');
}

}//submit closed
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.