PDA

View Full Version : Solved: PHP help please



austenr
05-31-2007, 09:50 AM
Hi,

Can anyone please explain what is wrong with this code. Yea, its a silly simple example I need to understand before I move on to the more complicated stuff. Thanks

<html><body bgcolor="#ffffff">
<h4>Tizag Art Supply Order Form</h4>
<form action="process.php" method="post">
<select name="item">
<option>Paint</option>
<option>Brushes</option>
<option>Erasers</option>
</select>
Quantity: <input name="quantity" type="text" />
<input type="submit" />
</form>

<?php
$quantity = $_POST['quantity'];
$item = $_POST['item'];
echo "You ordered ". $quantity . " " . $item . ".<br />";
echo "Thank you for ordering from Tizag Art Supplies!";
?>

</body></html>

I know its in the form action part but thats what I can't figure out.

lucas
05-31-2007, 11:55 AM
It is simply sending the results of the filled out form to the process.php to be processed. Your process.php will take the info and post it to a file, email it, etc. If you dowloaded the example somewhere you should have the process.php with it....since you say your just starting I assume you won't try to write it yourself.

austenr
05-31-2007, 12:08 PM
The problem is that I have another form that I have modified and written myself that I cannot get to work. I thought if I started small and simple I coul understand it easier. It's not that I don't want to try myself, it the understanding of getting it to work in it's most simplified version. I'm attaching a zip file of what I came up with on my project that wont work. Perhaps if you are still interested, you might have a look.

lucas
05-31-2007, 12:21 PM
Hi Austenr,
I opened the form.html and looked at the form...it's action is:
<form method="POST" action="postit.php">
so it's trying to send the info to the postit.php....where did you get process.php? Maybe you need to either change it in the code back to postit.php or change the name of the postit.php to process.php.

I don't have apache installed on my computer at present so I can't test this for you but it looks like the postit.php processes your data and uses sql to update the tes.mdb just as it is set up now...??

I think you just have a name conflict....change one or the other to match.
best I can see from here.

austenr
05-31-2007, 01:07 PM
Think you have the two mixed up. The first post was a silly test I used off of the internet as a learning tool. In the zip file, the file names are form, postit, and the db called test. Im not sure why it isnt working either. Someone on another board helped me with another problem. The script I sent him was identical to what I had. The code worked on his PC but not on mine. I just installed today, IIS on my work windows 2k machine and am pretty sure I got it configured correctly. Not sure why it runs on others machines and not on mine. If you get near a machine you can test it on that would be good.

Something else that has me stumped is that on my ISP server which runs PHP, when I hit the SUBMIT button on the form the browser populates with the code from postit and nothing else.

Thanks

austenr
06-01-2007, 03:06 AM
Can't seem to get PHP configured in Vista. Anyone tell me how to do that? Thanks I have the apache server up and running.

austenr
06-02-2007, 03:26 PM
Ok. I got most of my prblems ironed out. I finally got Apache and PHP on my home machine. The problem lies in the postit.php file in the .zip file above. Here is what is happening. When I press the Submit button on the form, the screen populates with the PHP code from postit.php instead of writing it to the access table. Can anyone that knows PHP take a look and let me know where my error is. This is a work assignment that is due next week. Thanks.

lucas
06-02-2007, 06:19 PM
That's a sign of an error ok...are you sure the test.mdb is in the same direcory? It appears to be looking for the BMCactive table in the test.mdb using sql connect.

Have you tested a simple hello world php script or something to assure yourself that php is installed an the path is correct?

austenr
06-02-2007, 09:35 PM
Hi Steve,

Yes Hello World" works just fine. So if I understand correctly, it is this path:

$conn = odbc_connect('Driver={Microsoft Access Driver (*.mdb)};
DBQ=C:\Users\Austen & Mary's Comp\Desktop\test','','');

That is my problem? All three of the files are on the desktop. Thanks

lucas
06-03-2007, 08:46 AM
I may be wrong austenr but I think you need all of these files below your apache directory....in a sub directory....there should be a users/ there or home...where the server resides.

austenr
06-03-2007, 06:23 PM
If you were testing files in apache, what would your file path look like? Sorry, really struggling with this one.

lucas
06-03-2007, 07:20 PM
you should look for a folder like apache\web\users or something like that in the apache installation directory.

attached is a file you can run to see if php is actually working

just type the path into your web browser address bar something like:
http://www.yourwebserver.com/phpinfo.php

if you can't get it to work then you aren't below php and apache in the file tree....or php isn't configured or installed...If it runs you will get a web page created on the fly by the php script that lists all of your php info...version...paths..etc.

austenr
06-03-2007, 07:48 PM
No definatly did nt work. If I test port 80 in the command prompt I get this message:

Your port 80 is actually used by:

Server Apache/2.2.4, PHP/5.2.2.

The title in the bar is c:\wamp\php\php.exe

I installed apache from this link:

http://www.wampserver.com/en/

It was self installing so I figured it was installed/configured correctly.