Page 1 of 1

Php and images

Posted: Mon Oct 31, 2011 3:57 pm
by musbah
Hello, I'm not here to beg for code or anything i just need some help as to something I'm doing.

I'm fairly good with php and I have been trying to do something with no luck.

I want to make 3 links and 3 hidden images. When you click on 1 link an image appears, when you click on the other one another image appears and takes the place of the first one.

I can easily do that with either css and javascript but I was searching for a way to be able to send the information to php.

For example if the person is seeing image1 then clicks submit i want php to be able to get the url or some way to say that the person chose image1 , same if he chose image 2 and image 3.

I know that php is server side and not client side but I'm trying to find a way to use ajax and all but I'm not really good at it.

I would really appreciate some place to start, like i said at the beginning not here to get someone to do my job I just need a place to start because up to this point I have got nothing.

Thank you, appreciate any help.

Re: Php and images

Posted: Mon Oct 31, 2011 4:18 pm
by ScOrPi
Hi , try this ajax ..


[text]var xmlhttp;
function GetXmlHttpRequest() {
xmlhttp = false;
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
xmlhttp = new XMLHttpRequest();

}
}
}

function load_img(iType) {
GetXmlHttpRequest();
xmlhttpt.open("GET","page.php?type="+iType,true) ;
xmlhttp.send(null);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
document.getElementById('someid').innerHtml = xmlhttp.responseText;
}
}
}
[/text]

and for your php page you can make switch or if ... etc .

but for easy way make it with js or jquery :)

Re: Php and images

Posted: Mon Oct 31, 2011 4:20 pm
by social_experiment
To retrieve any data from the url in php use $_GET;

Code: Select all

 <form action="page.php?id=5" method="post" />
To access the value of id you would use $_GET['id'] and it will contain a value of 5