i have created a login page where a student is able to register using username, password and email. I have created a table which contains all the students ID. So when a students registers they have to enter a correct ID which has to match the table in order for them to register. I was wondering how can i do this. I am using php and mysql.
f(isset($_POST["submit"])){ `if(!empty($_POST['user']) && !empty($_POST['pass']) && !empty($_POST['email'])) {
$user=$_POST['user'];
$pass=$_POST['pass'];
$email=$_POST['email'];
$con=mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('user_registration') or die("cannot select DB");
query=mysql_query("SELECT * FROM login WHERE username='".$user."'");
$numrows=mysql_num_rows($query); if($numrows==0)
$sql="INSERT INTO login(username,password,email) VALUES('$user','$pass', '$email')";
$result=mysql_query($sql);
if($result){ echo "Account Successfully Created"; } else {
echo "Failure!";
else { echo "That username already exists! Please try again with another.";
else { echo "All fields are required!";
i have not included the student ID part as i am unsure
No comments:
Post a Comment