The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> PHP script to allow selective id numbers for signup registration
shankar from vizag
post Jan 3 2020, 11:29 AM
Post #1


Advanced Member
****

Group: Members
Posts: 171
Joined: 18-June 13
Member No.: 19,316



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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jan 3 2020, 03:27 PM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,725
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
shankar from vizag
post Jan 5 2020, 10:46 AM
Post #3


Advanced Member
****

Group: Members
Posts: 171
Joined: 18-June 13
Member No.: 19,316



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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Jan 5 2020, 08:56 PM
Post #4


Programming Fanatic
********

Group: Members
Posts: 1,725
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 25th May 2020 - 11:23 PM