Help With if/else in PHP/MySQL

From: spacemancw (spacemancw_at_yahoo.com)
Date: 03/12/04


Date: 12 Mar 2004 09:36:52 -0800

I'm reading an article on MySQL/PHP at
http://hotwired.lycos.com/webmonkey/99/21/index3a_page4.html?tw=programming

It's very good for me starting out but I have a question.

I'm using OS X Panther 10.3.2

MySQL 4.0.15

PHP 4.3.2 (cli) (built: Sep 13 2003 22:04:20)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies

Apache/1.3.29 (Darwin)

Following the tutorial things are looking good up until "Throw in Some
Forms" in Lesson 2.
http://hotwired.lycos.com/webmonkey/99/21/index3a_page4.html?tw=programming
There is a form as follows

 .....snip..............

if ($submit) {

  // process form

  while (list($name, $value) = each($HTTP_POST_VARS)) {

    echo "$name = $value<br>\n";

  }

} else{

  // display form

 .....snip..............

and the next form after that also.
I pull up the forms which I have called fpage2.php and fpage3.php
In the first form fpage2.php, it should display the input fields the
first time you access it. Then when you fill it in, 'submit' now has a
value, so the return page should list the values just entered. It
doesn't, it just shows the form again.

In the next form fpage3.php, it should display the input fields the
first time you access it. Then when you fill it in, 'submit' now has a
value, so the return page should display "Thank you! Information
entered." and the data should be inserted into mydb. It doesn't, it
just shows the form again.

So it's as if the 'if/else' statement doesn't get a positive with the
if ($submit) {
and so it just moves on to the 'else'.

I just copied and pasted ther forms into a file using VI on the
command line and didn't edit them in any way.

Now this was for PHP 3. Is that fact that I have PHP 4 a problem. Is
there a change I should make?

Any help would be appreciated.

Thanx

rmc



Relevant Pages

  • Re: Help With if/else in PHP/MySQL
    ... I had trouble with thier tutorials also. ... it should display the input fields the ... >first time you access it. ...
    (comp.lang.php)
  • Re: Object Oriented Content System - the idea
    ... >I expected php to be smarter then that. ... >form like bytecode in memory for the next request. ... each action added some stuff to a "response" XML document. ... that map/object/data and formats it for HTML display using an includeed PHP ...
    (comp.lang.php)
  • Re: session trouble
    ... Note that you're building your display block AFTER your loop. ... <?php session_start; ... The problem here is going to be since you have multiple school clubs, it's going to be hard to relate a particular club to the entry in your database if it going to be changed. ... Another way is to add a suffix to each field, often times the primary key for the table. ...
    (comp.lang.php)
  • Re: Redirecting between PHP Pages
    ... but at the very least in a php script. ... > on the outcome of the validation, you want to do one of two things: ... with the various bits of HTML being ... Display login form ...
    (comp.lang.php)
  • Re: Open and process remote page
    ... William Hudson wrote: ... I have toyed with some of the php functions for opening URLs, ... > I need to fully emulate a browser, ... > display the remote page). ...
    (comp.lang.php)