Help - Search - Members - Calendar
Full Version: PHP script to allow selective id numbers for signup registration
HTMLHelp Forums > Programming > Server-side Scripting
shankar from vizag
Greetings

I will explain the problem with follwing example:



I have 100 student IDs. For a specific task, only 1 to 25 id numbers (selective students) should allow to self-register via web page. If I keep these 25 valid ID numbers in mysql table in the server database, how could be the login registration php script to allow those particular students to register and for rest, if they try to register, not to accept the registration.

I am trying and trying but not succeeded. Can anyone here guide me to overcome this issue.

Thanks in advance.

Regards
CharlesEF
This is how I would approach this:

Use PHP 'file_get_contents' and 'file_put_contents' to save the number of users that have registered (1 thru 25). No database needed.
When the login page is loading use that file to determine if the login screen should be shown (if less than 25) or an error message because 25 users have already registered.
If the login screen is shown and the user registers than you need to update the file to show new users registered count.

I can't offer anymore until you show some actual code.
shankar from vizag
QUOTE(CharlesEF @ Jan 4 2020, 01:57 AM) *

This is how I would approach this:

Use PHP 'file_get_contents' and 'file_put_contents' to save the number of users that have registered (1 thru 25). No database needed.
When the login page is loading use that file to determine if the login screen should be shown (if less than 25) or an error message because 25 users have already registered.
If the login screen is shown and the user registers than you need to update the file to show new users registered count.

I can't offer anymore until you show some actual code.


Thank you Charles Ji

With the following, I got solution for my issue.

<?php

$link = mysqli_connect("localhost","root","");
mysqli_select_db($link,"school");


//submit1 = FOR INSERTING RECORDS


if(isset($_POST['submit1']))
{
$id= $_POST['student_id'];
$message1= "Record Existed!!!";
$message2= "Record added successfully";

$check=mysqli_query($link,"select * from students where id='$id'");
$checkrows=mysqli_num_rows($check);

if($checkrows>0) {
echo "<script type='text/javascript'>alert('$message1');</script>";
} else {


$q= "INSERT INTO `dance_programme` (std_id) values ('$id')";
$query= mysqli_query($link,$q);
echo "<script type='text/javascript'>alert('$message2');</script>";
mysqli_close($link); // Closing Connection with Server

}

};
?>

Thank you
CharlesEF
If it is working for you then that is great. However, I see nothing about the first 25 users. As far as I can see, this script doesn't track that count. But you say you've got the solution so OK.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2020 Invision Power Services, Inc.