0
Hello!
My knowledge in PHP is basic, but I will understand the explanations better.
My goal is to create a home page index.php where it gets the resolution of the user screen and this data X and Y are stored in variables and so in a form. The page would automatically call another page where the JS variable values are used by PHP.
I have not yet learned Mysql to formulate a database. I have seen several options to send variables even per link, but none worked properly.
The little I know of JS is enough to automatically get the Review through this code below:
<script>
var x = screen.availWidth;
var y = screen.availHeight;
alert("LARGURA: "+ x +"\nALTURA: " + y)
</script>
of course without Alert for the page come to be able to call another without user intervention.
I know in my researches that in a single file you can’t use the JS variables in PHP because PHP runs on the server and JS runs on the user
As you can see I thought of using a form that auto fills with the value of JS variables. The problem that in JS I am more than Noob. So in the other file called then php would use the data that is saved in the form.
I saw some alternatives here, but none I could actually use properly and it came to mind that this alternative will be faster.
Thank you in advance.
When the user arrives at the page you want to redirect to another page whose PHP knows the screen size, right? which is the url of the other page?
– Sergio
I didn’t exactly decide, but I would link to a login page. The idea is that this first page does not take more than a few seconds and automatically loads to the next one already with the user screen resolution data. I put the first one as index.php for having already told me that the server always looks for this to run first.
– Djpessoa
If you explain better why you need to know the size of the screen.
– Sergio
Sergio. As I explained below is because of the css. When I was modeling the page I realized that when I minimized the browser screen everything went out of place. So I created a div that involved everything of the site and it worked. However I started to think that the page could model itself according to the user. I saw that you can use php variables in the stylesheet page, changing . css to . php and adding some details. So if I have the values right away the page can adapt automatically using php variables with the values obtained in this first call. Understands.
– Djpessoa