Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You were not closing the else bracket and also <code>mysql_select_db()</code> is a function not <code>mysql_select_database()</code>. use this code. </p> <pre><code> &lt;?php $con=mysql_connect('localhost', 'root', '') or die (mysql_error()); mysql_select_db('db',$con) or die (mysql_error()); if (isset($_POST['submit'])){ $myusername=strtolower($_POST['username']); $name=strip_tags($_POST['name']); $mypassword=strip_tags($_POST['password']); $password1=strip_tags($_POST['password1']); $role=strip_tags($_POST['role']); $gender=strip_tags($_POST['gender']); $matric=strip_tags($_POST['matric']); $college=strip_tags($_POST['college']); $faculty=strip_tags($_POST['faculty']); $course=strip_tags($_POST['course']); $email=strip_tags($_POST['email']); $phone=strip_tags($_POST['phone']); $errors = array(); if (empty($myusername) || empty($name) || empty($mypassword) ||empty($password1) || empty($role) || empty($gender) || empty($matric) || empty($college) || empty($faculty) || empty($course) || empty($email) || empty($phone)){ $errors[]= 'Please fill in &lt;b&gt;*ALL*&lt;/b&gt; fields! &lt;a href="registration.php"&gt;Back&lt;/a&gt;'; } else{ if ($mypassword!=$password1){ $errors[] = 'Password does not match'; } if (strlen($myusername)&gt;30){ $errors[] = "Length of username is exceed &lt;b&gt;MAX&lt;/b&gt; limit! Must be less than 30 characters"; } if (strlen($mypassword)&gt;25 || strlen($password)&lt;6){ $errors[]= "Password must be between 6 to 20 characters. &lt;a href='registration.php'&gt;Back&lt;/a&gt;"; } } if(!empty($errors)){ foreach($errors as $error){ echo $error, '&lt;br/&gt;'; } } else{ mysql_query("INSERT INTO student (username, name, password, role, gender, matric, college, faculty, course, email, phone) VALUES ('".$myusername."', '".$name. "', '" .$mypassword. "','" .$role. "','".$gender."','". $matric."','".$college."','".$faculty."','".$course."','".$email."','".$phone."')"); echo "&lt;strong&gt;You're SUCCESSFULLY registered! You are now one of the volunteers&lt;/strong&gt; You can now &lt;a href= 'index.php'&gt;Login&lt;/a&gt; here!."; exit(); } } else{ ?&gt; &lt;tr&gt;&lt;td bgcolor="orange"&gt;&lt;table cellpadding='0' cellspacing='0' border='0' width='100%'&gt;&lt;tr&gt; &lt;td bgcolor="orange" align=center style="padding:2;padding-bottom:4"&gt; &lt;font size=-1 color="white" face="verdana,arial"&gt; &lt;b&gt;Registration Form&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td bgcolor="white" style="padding:5"&gt;&lt;br&gt; &lt;form method="post" action="index.php" name="registration_form" target="_top"&gt; &lt;center&gt; &lt;table&gt; &lt;tr&gt;&lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;Username &lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="username" size="60"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;Name&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="name" size="60"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;Password &lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="password" name="password" size="60"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;Verify Password &lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="password" name="password1" size="60"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;Role&lt;/font&gt;&lt;/td&gt;&lt;td&gt;&lt;select name="role"&gt; &lt;option value="student"&gt;Student&lt;/option&gt; &lt;/select&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;Gender&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;select name="gender"&gt; &lt;option value="male"&gt;Male&lt;/option&gt; &lt;option value="female"&gt;Female&lt;/option&gt; &lt;/select&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;Matric &lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="matric" size="60"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;College &lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;select name="college"&gt; &lt;option value="a"&gt;A College&lt;/option&gt; &lt;option value="b"&gt;B Residential College&lt;/option&gt; &lt;option value="c"&gt;C Campus&lt;/option&gt; &lt;/select&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;Faculty &lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;select name="faculty"&gt; &lt;option value="ABC"&gt;ABC&lt;/option&gt; &lt;option value="XYZ"&gt;XYZ&lt;/option&gt; &lt;/select&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;Course &lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="course" size="60"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;Email &lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="email" size="60"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;Phone Number &lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="phone" size="60"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font face="verdana,arial"&gt; &lt;input type="submit" name="Submit" value="Submit"&gt; &lt;/font&gt; &lt;input type="reset" name="reset" value="Reset"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan=2&gt;&lt;font face="verdana,arial" color="black" size=-1&gt;&amp;nbsp;&lt;/font&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/center&gt; &lt;/form&gt; &lt;?php }?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload