Before I give you my issue let me explain what the website is about so you can get enough understanding of what I’m trying to do.
The website is Wordpress based. It’s a platform for customers to book an appointment with a life coach/therapist. The appointment is for scheduling a session /video call within the website.
Question:
I am going to use jitsi for video calling. http://meet.jit.si/123
Now in the customer’s dashboard and the coach’s dashboard there will be a button to join the call.
So what I need help with:
1- How to generate random number after a url
2- how to make 2 buttons generate same random number if booking info is met for both users.
You cant’. It wouldn’t be a random number if you could generate it twice! Presumably you’re using a database, so one user (probably the therapist, but it shouldn’t make any difference) generates the random number, stores it in the database, and when the client preses their button it fetches the stored number from the db. Would that work?
So what for do you need a random number? Your appointment may have an ID, or you have client + coach ID. Just concatenate them with an underscore, or md5 them before using.
Now this is where the coach will click the button and open the window in a new tab where the random number is generated
Ex:
meet.jit.si/1234
Now what I need help with is:
how to let that “1234” be shared with the customer who have the appointment with the coach?
so when the custom clicks that button it takes him to the same “1234” room
As @Gandalf already said. Stick it in the database, pass a unique id to the client so it can be retrieved. But if you’re going to do that, you might as well do as @chorn said earlier, drop the random number and just use a combination of various unique elements from the database table, encoded if you need to.
One issue you might encounter with random numbers is that they can repeat. So if you generate a random now, there’s a chance the same number might appear and, being random, you have no idea or control over when that might be - if you’re on a hosted platform, you might have a situation where each new session on your site runs on a different CPU, for example. What happens if it occurs close together in time, and you end up sending the same one to two different clients?
Every time you call the randomNumber() function it generates a new one. So in your comparison it would compare to a new value, except that the function displays the number as part of a link, rather than returning it, so you can’t really use it for comparison purposes anyway. I’m not sure what value PHP uses for a function that has no return. (ETA - it uses false).
Where does $gotNumber come from, in your comparison?