Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Learning PHP 2

Status
Not open for further replies.

hillbillyfritz

Technical User
Mar 28, 2001
34
US
I am interesting in writing a code for my website, and I would like to use PHP. I want to have a progressive form that allows users to build a car. They will choose the color, click next, and a new page will appear with a picture of that color car. Then they will choose another option and the next page will show both the color and the next option and so on and so on. When they are finished I would like the results emailed to me. Since I'm very inexperienced with PHP, what will I need learn to accomplish this? Thanks very much.
 
The one thing u need to learn is how to pass variables from one page to another. This can be done with forms, on the next page the name attrib of the inputs of the form is available as variable.
So start with learning all about variables and control structures: mcvdmvs
-- "It never hurts to help" -- Eek the Cat
 
Hi, I just added an FAQ on where to learn more about PHP. So take a look at that for some ideas on where to start.
 
Thanks! I am having a problem though. The script is just printing both images, no matter what is selected on the form. Is there something I need in my PHP script to get the variable from the form?
Here is my form:
Code:
<form action=&quot;imgtest.php&quot; method=&quot;post&quot;>
	<input type=&quot;radio&quot; name=&quot;color&quot; value=&quot;blue&quot;>Blue<br>
	<input type=&quot;radio&quot; name=&quot;color&quot; value=&quot;green&quot;>Green<br>
<input type=&quot;submit&quot; value=&quot;submit&quot;>
and my PHP:
Code:
<?php
if ($color = blue){
print &quot;<img src=\&quot;blue.gif\&quot; width=\&quot;25\&quot; height=\&quot;25\&quot;>&quot;;
}
?>
<?php
if ($color = green){
print &quot;<img src=\&quot;green.gif\&quot; width=\&quot;25\&quot; height=\&quot;25\&quot;>&quot;;
}
?>
What am I doing wrong? In the form should &quot;color&quot; be &quot;$color&quot;? Thanks in advance.
 
You are using the assig operator instead of compare.

if($color == &quot;green&quot;)...

[bb]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top