Page 1 of 2
Despite good help, still can't get this form post working
Posted: Thu Jul 10, 2003 5:17 pm
by mikeb
Hi,
I posted for some help as a php newbie. Great response but night #3 and it's still not working. Been through a re-install of php etc. I can do what I like with variables on one php page such as adding, subtracting variables etc. so php SEEMS to be working on my server. My problem is that I'm trying to post a simple set of variables from a form on a html page to a receiveing action page. When I post the form, there is simple a blank page! My html header and footer source code is viewable when I look at the source code, but the php code has not been processed.
There is no error in my Apache log to indicate anything going wrong. I'm using php 4 and Apache 2 on a W2K PC. Can someone give me a simple piece of code to check whether a form post is working or not.
I'm an experienced html and ColdFusion coder so I'm not new to web coding and am pretty sure my html is ok in my samples. Is there a possible php configuration error that I'm not picking up?

Posted: Thu Jul 10, 2003 5:21 pm
by jason
If that runs, PHP is working. Next step would me to let us look at some code (post it here).
Posted: Thu Jul 10, 2003 5:23 pm
by bionicdonkey
to see if php is working corectly, create a new page with php extention and include the following code:
Posted: Thu Jul 10, 2003 5:44 pm
by mikeb
Ran php info command.
Everything worked fine. Html output showing my system settings
==========================================
Here's my form code (stripped to the bare essentials)
==========================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<form method="post" action="formaction.php">
<input type="text" name="FirstName"><br>
<input type="submit" name="submit">
</form>
</body>
</html>
============================================
Here's my action page
============================================
<html>
<head>
<title>hello</title>
</head>
<body>
<?php
echo "$_POST['FirstName']";
?>
</body>
</html>
============================================
When I post this form, I get no error, no error in my Apache
log either. Here is the processed html from 'view source'
============================================
<html>
<head>
<title>hello</title>
</head>
<body>
</body>
</html>
============================================
Here is an error messag I get when I single quote the variable
as ['variable'] on the action page as suggested on the forum
============================================
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE'
or `T_NUM_STRING' in C:\webroot\Sandbox\phpLearning\
formaction.php on line 11
============================================
I feel myself moving back to ColdFusion!!!
Mike
Posted: Thu Jul 10, 2003 5:52 pm
by kcomer
Try removing the double quotes around the echo command but leave the singles around the form name. It should work.
Keith
Posted: Thu Jul 10, 2003 5:58 pm
by redhair
mikeb wrote:I feel myself moving back to ColdFusion!!!
Nooooo!! Yourre doing great! Just a little error...that's all

Posted: Thu Jul 10, 2003 5:59 pm
by mikeb
Took the double quotes off the echo command. Can't find the 'Form Name' as I haven't named the form? Still getting clean html when I view source!
ps. I've a biker friend in work and I'll send him your url!
Mike
Posted: Thu Jul 10, 2003 6:02 pm
by redhair
Posted: Thu Jul 10, 2003 6:05 pm
by mikeb
Nope! still not working with Red Hair's code. Syntactical nightmare! I've still got the clean html with no sign of php being processed - although, no error messages. This is going to turn out to be something really stupid on my part.
Posted: Thu Jul 10, 2003 6:08 pm
by mikeb
Can't wait to start on my SQL connections!
Posted: Thu Jul 10, 2003 6:12 pm
by redhair
ehhh... ok...hey i'm just a newbie

Posted: Thu Jul 10, 2003 6:18 pm
by mrvanjohnson
Odd, I just copied and pasted your code onto my server and with redhair's correction it ran fine. It must be a configuration problem.
Something is not right.. If Apache wasn't processing the PHP at all then you would see it in the source. I know this is fundamental but you need to confirm your action is submitting to the correct PHP page. I've been so bone headed before to have a similar problem only to turn out I was working on the wrong page... Is your server accessible from the internet? If so, can you give us the URL to the phpinfo file? Not sure what I expect to find but it couldn't hurt.
Posted: Thu Jul 10, 2003 6:20 pm
by mikeb
Thanks Red Hair. That was not supposed to be a bad comment. I really appreciate the help.

This forum is brilliant, really like the quick response from people who know their stuff better than me. I've got to go get some sleep (12:30am here), I've got a client meeting in the morning.
Thanks for the help and I'll keep the faith. I know php is cool - just need to get to know it,
cheers,
Mike

Posted: Thu Jul 10, 2003 6:24 pm
by redhair
No problem at all...it was not meant that way.
I just was as lost as you are with your problem. When i can't find the solution...i feel like a newbie

Posted: Thu Jul 10, 2003 8:39 pm
by jason
When you wake up, could you do two things. First, give us an update of the exact code you are using on your action page (the one giving you the problem), and also, if you could, the Url where we can test this out. From what I see, the suggestions so far should have worked. Also, one final request, a Url to your phpinfo() page, so we could take a look at the configuration. Maybe something is barfed, but I doubt it.
Code: Select all
<html>
<head>
<title>hello</title>
</head>
<body>
<?php
echo $_POST['FirstName'];
?>
</body>
</html>
This is what you should have.