Andre, Yes, the html page with your input form effectively ends with the </form> tag so any decision statements on that page past that tag would miss the form input. So, put any decision statements on the php page where you've put your database code. I'm sure someone will educate me on the above statements, and I'll likely deserve it. When you eventually use the $php_self call, you can put everything on one page above the form start.
You can have as many <?php ?> calls on an html page as is needed to complete your tasks. However, I use php to do some rather complex math (it's complex to me at least), so I got in the habit of using php throughout a page without breaking out for html. For me it is more readable. My $00.02 on books, I bought a Sams 24 hour book on php for $25, and it got me off the ground. The online manuals for php and mysql have also been invaluable. Save your money, buy food instead. Hope this helps, Hugh ----- Original Message ----- From: "Andre Dubuc" <[EMAIL PROTECTED]> To: "hugh danaher" <[EMAIL PROTECTED]> Sent: Tuesday, March 05, 2002 6:35 PM Subject: Re: [PHP] Is there a "GoTo Page" Function? > Hi Hugh, > > Well, actually my next question you've sort of answered: "Where do I put this > code?" With all the new information coming at me, I haven't had time to think > it through -- but I gather from your response, the answer would be: 'Put it > before the database code rather than in the html page.' Am I correct? > > One other question: I gather it's OK to have multiple instances of <?php .... > ?> on the same html page or in the same php page? > > I realize that these are pretty fundamental questions. As soon as I can > scrape up eighty dollars I'll buy a book on PHP and another on HTML. In the > meantime, I would greatly appreciate it if you could clear up these basic > assumptions for me. > > Thanks for your help! > Tia, > Andre > > > On Tuesday 05 March 2002 20:36, you wrote: > > > > > Andre, > > My note on decision lines was in anticipation of your next question/problem > > of "How do I handle things if the user doesn't fill in his name, address, > > whatever?" My solution is check to see if the cell is filled and if not > > then quit the database storage and tell the person to fill in the info. I > > first check to see if the data is set and if not, send a message. This > > would come before wasting your time storing anything. There are many other > > methods to check user input but I learned the if (!isset($something)) die() > > method first, and to me it's the most straight forward. > > Hope this helps, > > Hugh > > ----- Original Message ----- > > From: "Andre Dubuc" <[EMAIL PROTECTED]> > > To: "Erik Price" <[EMAIL PROTECTED]> > > Cc: <[EMAIL PROTECTED]> > > Sent: Tuesday, March 05, 2002 4:56 PM > > Subject: Re: [PHP] Is there a "GoTo Page" Function? > > > > > On Tuesday 05 March 2002 19:20, you wrote: > > > > On Tuesday, March 5, 2002, at 07:01 PM, Andre Dubuc wrote: > > > > > Now that makes sense. I'm getting a better idea of how it works > > > > > together. I > > > > > figured there must be a way to control the "Submit" button's > > > > behaviour, > > > > > > > but I > > > > > didn't know where to look. > > > > > > > > Yep, the submit input tells the form "go do your thing", but the form > > > > already knew where to go (because you specify where to go in the > > > > 'action' attribute). The form also knows how to go -- whether it > > > > should be POST or GET. Without realizing it, you'll be learning more > > > > about the HTTP protocol itself as you start writing scripts that take > > > > advantage of its features. > > > > > > > > > Where would you insert: > > > > > > > > > > if (!isset($name)) die ("You need to fill in your name. Use the > > > > > browser's > > > > > back button and input this information."); > > > > > > > > > > I tried in the php database storage code (didn't work). Tried it > > > > > after the > > > > > appropriate 'Name' code in the form's html document. Didn't work. I > > > > know > > > > > > > that it should work somewhere . . . . > > > > > > > > > > Somehow, I don't think the "Submit" function is working as it should > > > > > (especially if a carriage return or "Enter" can override everything). > > > > Is > > > > > > > there some code that will defeat this undesirable activity? > > > > > > > > Firstly, your browser is what determines how the form is sent -- but > > > > usually, it's normal for the Enter key to act as the "Submit" button (a > > > > nice keyboard shortcut that I take advantage myself). It should not > > > > act in this fashion if you are typing into a textarea tag, because you > > > > might want to enter newlines/cr's in the textarea, but for most other > > > > form fields it's normal. If you want to jump from one field to the > > > > next with a key press, use tab. > > > > > > > > Secondly, you're wondering where to check for the presence of the data? > > > > How about this: > > > > > > > > <?php > > > > function print_name_form() > > > > { > > > > print "<p><input type=\"text\" name=\"name\" /></p>"; > > > > } > > > > > > > > if (!$_POST['name']) { > > > > print "<p>You need to fill in your name.</p>"; > > > > print_name_form(); > > > > } else { > > > > print "<p>Thank you!</p>"; > > > > } > > > > ?> > > > > > > > > Why did I define a function in the beginning? Well, this way, if the > > > > user didn't enter a name, they don't have to hit "back" in their > > > > browser. The form just appears again. This is much more useful if you > > > > have this same function accessible from each page/script you are > > > > writing, so that you don't have to waste your time. Later, when you > > > > learn how to check for errors in your user's input (such as if the user > > > > entered a bunch of numbers instead of a name), this will come in handy > > > > so that you can save the user's legitimate values but ask them to > > > > re-enter their invalid values. That gets kind of technical, but it's > > > > one of the sweet things about functions, that they are reuseable. > > > > > > > > Erik > > > > > > Hi Erik, > > > > > > And thanks again! > > > I like the 'function print_name_form()' -- I gather you could do this for > > > > all > > > > > the NOT NULL variables that a form requires. Further, would you just > > > > change > > > > > the "print_name" to 'print_whatever-other-variable' that I would want to > > > check? Is there another way to consolidate the code at this point? Or > > > > would I > > > > > just duplicate the code for each not-null variable? > > > > > > [Btw, I sometimes long for the old Paradox PAL code that seemed so > > > > difficult > > > > > at the time I learnt it -- PHP is very similar, but the syntax seems so > > > > much > > > > > more compact.] > > > > > > While we're on the topic of fields ('input type=text") is there anyway to > > > include a non-printing space in the data entry, say for 'Name", that > > > would not be passed to the database? Thus, on the screen it would appear: > > > > > > Name: [non-printing space]Andre but in the database entry: Name:Andre > > > > > > This isn't a pressing question, and probably is a formatting question, > > > but > > > > I > > > > > wonder if it's possible? > > > > > > Tia, > > > Andre > > > > > > > ---- > > > > > > > > Erik Price > > > > Web Developer Temp > > > > Media Lab, H.H. Brown > > > > [EMAIL PROTECTED] > > > > > > -- > > > Please pray the Holy Rosary to end the holocaust of abortion. > > > Remember in your prayers the suffering souls in Purgatory. > > > > > > May God bless you abundantly in His love! > > > > > > For a free Cenacle Scriptural Rosary Booklet -- > > > > http://www.webhart.net/csrb/ > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > Please pray the Holy Rosary to end the holocaust of abortion. > Remember in your prayers the suffering souls in Purgatory. > > May God bless you abundantly in His love! > > For a free Cenacle Scriptural Rosary Booklet -- http://www.webhart.net/csrb/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php