PHP, What am i doing wrong?

Soldato
Joined
27 Aug 2004
Posts
17,111
Location
Geordieland
Below is some simple PHP coding, but i cant see what im doing wrong with it. Can anyone guide me as to where my balls up is please? The submit button is working but when i am hitting submit its just displaying $camelChoice"; ?>

HTML
Code:
    <form action="adopt.php" method="get">
    <p>
		Select your camel type:
    </p>
        <select name="CamelType">
        <option value="MaleBac">Male Bactrian</option>
        <option value="FemaleBac">Female Bactrian</option>
        <option value="MaleDrom">Male Dromedary</option>
        <option value="FemaleDrom">Female Dromedary</option>
        </select>
    </form>

PHP Response
Code:
	<?php
		$camelChoice = $_GET['CamelType'];

		echo "<p>Camel Type: $camelChoice</p>";
	?>

Any help hugely appreciated.
 
Stellios said:
did you upload it onto a web server? Im trying to do it just offline and it wont have it at all.

You are using a PHP enabled server offline right?

Sorry if thats a really daft question.
 
Jaffa_Cake said:
You are using a PHP enabled server offline right?

Ah crap, forgot to get the offline apache web server files, that would be why. Anyone fancy slapping me :o

Can you tell its the first time ive used PHP :p
 
Sitting here now with apache etc enabled and i cant get it to work. The values are passing over but i cant get them to print out onto the screen?

Any help greatly appreciated.

Code:
EDIT - sorted :)
 
Last edited:
you have apache installed but are you sure php is working? unless you downloaded one of those all-in-one package things (lamp, wamp, xammp?), then you'll need to add/configure php separately.

you can test your php by saving this into a new php file.....

Code:
<?php
phpinfo();
?>

then access it a browser. you should get a page like this.....

2002213967038920746_rs.jpg
 
Yep its working

Code:
PHP Version 5.0.4

System 	Windows NT C71174428 5.1 build 2600
Build Date 	Mar 31 2005 02:44:34
Configure Command 	cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"
Server API 	Apache 2.0 Handler
Virtual Directory Support 	enabled
Configuration File (php.ini) Path 	C:\WINDOWS\php.ini
PHP API 	20031224
PHP Extension 	20041030
Zend Extension 	220040412
Debug Build 	no
Thread Safety 	enabled
IPv6 Support 	enabled
Registered PHP Streams 	php, file, http, ftp, compress.zlib
Registered Stream Socket Transports 	tcp, udp
 
first of all change your form method to post. stops the ugly urls with all the values appended to the end. you'll need to update your adopt.php and change all those get requests.


next,

Code:
echo "<p>Name: $name</p>";
		echo "<p>EMail: $email</p>";
		echo "<p>Billing Method: $billingMethod</p>";
		echo "<p>Telephone No: $tel</p>";
		echo "<p>$address</p>";
		echo "<p>$postcode</p>";
		[COLOR=Red]<br />[/COLOR]
		echo "<p>Camel Type: $camelType</p>";
		echo "<p>Shovel Extra: $Shovel</p>";
		echo "<p>Saddle Extra: $Saddle</p>";
		echo "<p>Brush Extra: $Brush</p>";
		echo "<p>Foot File Extra: $FootFile</p>";

note the bit in red. and lastly. and lastly you have a typo with the capitalisation in "footFile". change that so the form and processing page are the same. :)
 
Last edited:
Ive already clicked about changing it to post and done it. Ill cry if ive spent the last 3 hours crying at dreamweaver if its a simple few typos.
 
Stellios said:
Ive already clicked about changing it to post and done it. Ill cry if ive spent the last 3 hours crying at dreamweaver if its a simple few typos.

it is just typos. because i tested it myself to get it working. :p

edit: too slow.

edit2: you should turn on error reporting. php usually gives you a good idea of where the error is. that's how i found it without having to scan through your code. :)
 
Last edited:
Back
Top Bottom