Forum Moderators: coopster
you will need to find and subscribe to an SMS gateway provider. The usual way is that after your subscription you get an interface description from the gateway people on how to send an SMS via your site and how to receive the answers in your site. Mine does this by calling a certain page on my site and sending the sms text and number in the URL as querystring which I in turn process using the $_GET superglobal. You can then do just about anything to alert the user of this incoming SMS - send a mail, send him an sms, ring his phone, whatever. This adresses topic 1 in your posting.
Topic 2: Opening new windows is a JavaScript issue, or just plain <a href="http://..." target="_blank"></a>
Topic 3: Your script which receivces the SMS should store them in a database, or, clearly second best, some form of flat file to present it to the offline users at their next visit to your site at a later time.
All in all this is not an easy task to accomplish, as you want to take approprate measures to avoid unauthorized people sending SMS through your system at their will. You will certainly have to pay for each SMS that you send via the gateway. Thus some sort of user authentication and SMS counter is mandatory, and once it's your money you should be very careful. Some SMS gateway providers let you place hard limits on how many SMS may be sent per hour/day/month. Consider placing reasonable limits even at the risk of your users not being able to send any more SMS once the limits are reached.
Regards
Markus
and what about database, where i can store it, because users can be about million and not best decision i think to place it in MySql. May be use DMB, or common files?
Thanks a lot for answer)
So you want your users to communicate trough a messaging system on your site.
Well, have the sender type the message and the recipient's name/id/nick/whatever in a form, process the form (validate input on server side!) and store the data into a database, together with all the necessary admin info such as timestamps and stuff. mySQL will do the job perfectly for most sites; you'll have to monitor the processes to see if it suits your specific needs. Averages of 100 queries/second and above are no real big deal for mySQL.
Next, incluce a snippet of code on every page your users can access, (something like 'include("messages.php")' ) which searches the database for new messages for the user. If there are any, you can present them to the user in the main window, or have PHP write the JavaScript code to open a pop-up window. Keep in mind though, that A LOT of users block pop-ups altogether, and that quite a few of them disable JavaScript completely.
You don't have to bother whether the recipient is online or offline, because he sees the messages the next time he hits one of your pages. You could of course check if the recipient is online at send time and send him an alert mail if he is not. Well, I guess you could do just about anything you want...
Happy messaging anyway.
Regards
Markus
PHP can't monitor the client state and can't create a pop-up. At best, PHP can have a "timeout" function so that anyone who has requested a page in the last X seconds will be considered online, but that's not a real time thing.
PHP also can't tell someone that a message has arrived. You will need a client-side program that periodically sends a request to the server to find out whether any message has come in. If it has, it could then open a window. Only at that point could a PHP script take over by requesting the message from the DB server.
Either you decide that the user will be presented with his messages the next time he actively requests a page from your server, or you have some sort of background html document, say in an invisible (1px) frame or a blur()ed popup which requests the appropriate php script every n seconds using JavaScript or "META refresh" stuff which is considered a rather bad habit and can be turned off in several browsers, just like Java Script.
Remember how HTTP works: Client establishes connection to server, client requests document, server serves this request, connection is dropped. PHP is server side scripting and cannot actively open a connection to a client browser. The browser is simply not LISTENing on any ports on the user's machine. Any given firewall would be expected to prevent such a connection from the insecure outside anyway.
Any further approach into the "server push" technologies requires extra pieces of software to be installed on the user's machine to work as intended.
PHP can indeed monitor the server state, because it's running on the server. I can't see why you are voting against mySQL. Have a closer look at www.mysql.org and see what it was developed for. IMHO it seems the ideal tool for what you want to do. Some of my tables have far over 2M rows and there's nothing wrong with that. Keeping track of the user's last poll for messages is a simple task of UPDATEing the users table with a timestamp. Comparing this timestamp to the timestamp of the user's messages is just as easy and can be done in a single SQL query. www.php.net gives you all the information on which functions to use.
Thorough database design in the first place rewards your spent hours with scaleability and constantly good perfomance over time. Advice on this goes far beyond the scope of this forum though. There are quite a lot of resources on this topic. (Google for Entity Relationship Models, DB normalization, DB Indices, SQL queries using JOINS, etc.)
Regards
Markus
please forgive me if I am wrong, but from your questions i take it that you are not the most experienced programmer. [php.net ] is one of the best sites I have seen for ages in terms of documentation availability. Probably all of your questions will be answered there, at least all of mine have been so far. If it doesn't help you, you are most likely lacking the conceptual approach of software design.
As Mincklerstraat stated in your other thread in this forum [webmasterworld.com ] you should start off with a much, much less complex project involving database manipulation to get the feel of how get things straightened out.
Projects in the dimension you outlined in your postings are by far out of reach for someone who doesn't know how to query a database or how to produce any given output to a client.
Sorry, but my help must end here.
Regards
Markus
Have you downloaded the Windows Help (.chm) version of the manual in Russian yet? Books are fine of course, but I mostly learned PHP from the manual and this forum. This forum doesn't have a Russian translation yet, but the manual does:
[php.net...]
[us2.php.net...]
Cheers,
Tom