0
Good morning guys, I have a question in PHP. I have a page on my site that contains a form that sends the information from it to a validation page that connects and sends the information to the database. However my site has a desktop and mobile version and wanted to create a string "$mododeuso" in both pages but each with a different value to be passed to the validation page and be added together in the database. Is there any way to do this by input from the post? In case I couldn’t do it?
And what value would that variable have ?
– Diego Souza
in the case of the web page "computer" and the mobile page "mobile"
– Fratura Exposta
would be to record in the comment in the database which platform the person used to send the comment. My page has a mobile identifier, when it opens the index it makes the check and if it is mobile it opens m.index that brings the whole site structured for a mobile version
– Fratura Exposta
in case I need to create the string in the comment pages, Desktop and Mobile, and pass it to the verification page that fa the connection with sql and save the information in the database. Already all ready just wanted to add this function so "hidden" in the codes.
– Fratura Exposta
May I suggest you use the Detectmobilebrowsers. It can help you do this with a few lines of code in JS or other languages. http://detectmobilebrowsers.com/
– Diego Souza
Broder, I do not need to make an identification, I already have the code that does it, I would just like to create a string on each page to send to the database, on my page has a control panel where Adm can see the comments among others.
– Fratura Exposta
without taking into account that this code only sends to another page when the mobile is identified, it is almost equal to the code used to make the identification of the website and mobile, if you want to take a look at the site in action http://fracturexposta.esy.es
– Fratura Exposta
So in the function you do the check sends a value to a field
hidden
in HTML and send via POST.– Diego Souza
It worked 100% Brow vlw, ta adding right in the database the information I wanted. just for the guys check I used in the case "<input type="Hidden" name="mododeuso" value="Smartphone">" in the mobile page and "<input type="Hidden" name="mododeuso" value="Computer">" in the desktop version and in the verification page, which is the same for the 2 versions, put "$mododeuso= $_POST['mododeuso'];" to get the Sting and add the information to the database
– Fratura Exposta
I will not vote to close because I understand the problem (I understand that the AP simply wants to know how to detect the type of client - desktop or mobile - and send this information along to the form). But the question should be edited to be direct and clear. By the way, @Fracture exposed, if you managed to solve it would be good to add yourself an answer to help other future readers. :)
– Luiz Vieira
An answer myself to help future readers? like the one above that worked and what did I do to happen? or that I post all the codes of a 3 or 4 PHP files here? I swear I didn’t understand what you meant
– Fratura Exposta
So to be as clear as possible, in case I have a website that has a desktop version to be viewed on computers and a mobile version aimed at smartphones and that work in individual ways of each other. Inside each contained a page with a FORM to contact " the ADM team " of the page.
– Fratura Exposta
I had the initial idea of creating a string ($) on each page with the same name but each one with different values ( one Computer and the other Smartphone ) that was sent to the code page of the verifier.php, which would have the database information to store, the code with the functions to be executed in the database and the error or success messages, to be inserted in the database along with the Form information. D
– Fratura Exposta
Thanks to @Gumball who hinted to use Hidden I created an input that does not appear on the page with this value and with the value I needed for each page as in this example:' <input type="Hidden" name="mododeuso" value="Computer"> ' for the computer page and '<input type="Hidden" name="mododeuso" value="Smartphone">' for smartphones. In the check page I put a string to get the information of the form through POST '$mododeuso = $_POST['mododeuso'];' and sent this information along with the others to the database
– Fratura Exposta