Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Server-side Scripting _ PHP script to allow selective id numbers for signup registration

Posted by: shankar from vizag Jan 3 2020, 11:29 AM

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

Posted by: CharlesEF Jan 3 2020, 03:27 PM

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.

Posted by: shankar from vizag Jan 5 2020, 10:46 AM

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

Posted by: CharlesEF Jan 5 2020, 08:56 PM

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.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)