Page 1 of 1

error checking + include 'news.php';

Posted: Wed Feb 09, 2005 10:14 pm
by Jim_Bo
Hey,

I have now put my forms etc into functions so I can maintain them in a single page .. but where include 'news.php'; showed the form again when a field was missed obviously doesnt work using function with switch ..

How can I acheive the same thing now ?


Thanks

Posted: Wed Feb 09, 2005 10:20 pm
by djot
-
Hi,

Code: Select all

if form is not submitted OR submitted but filled incorrectly
{
  // show form again
}
else if form is submitted and filled correctly
{
  // include and output news.php
}
Don't know if this was the question ... pehaps you should reask it more clearly...

djot
-

Posted: Wed Feb 09, 2005 10:21 pm
by feyd
you're not making any sense Jim_Bo.

Posted: Wed Feb 09, 2005 10:25 pm
by djot
-
you're not making any sense Jim_Bo.
That's what I mean with lazy people - not even able to ask their questions properly.

Now you can booooooooooo again.

djot
-

Posted: Wed Feb 09, 2005 10:42 pm
by feyd
djot wrote:Now you can booooooooooo again.
o.O - I never boo'd.. that was Phenom. :)

Posted: Wed Feb 09, 2005 10:53 pm
by Jim_Bo
Hey ..

I will explain it with more depth ..

I had my edit news script on seperate pages .. ie the form was on one page while the script to make the updates was on another page ..

news.php - newsparse.php

I have now put then into one page using:

Code: Select all

function news() {

bla bla

}

function editnews() {

bla bla

}

switch ($_REQUESTї'cmd']) {

case 'news':
news ();
break;

case 'newsparse':
dbconnect ();
newsparse ();
break;
as an example ...

Before when the error checking took place the form was on news.php .. If a field was not filled in I was able to show the form again .. ie:

Code: Select all

if(!$news){
	
	echo ("Error! Fields marked * are required.");
	
	include 'news.php'; 
	
                return;
Now that I am using functions as above, I am not sure how to display the form again when required fields are missed?

Hopefully thats clearer ..

Thanks

Posted: Wed Feb 09, 2005 11:09 pm
by feyd
watch the insults now..

I would guess that news() displays the news? call it.

Posted: Wed Feb 09, 2005 11:39 pm
by Jim_Bo
Hey,

Thanks fyed .. I managed to get one of them to work with:

Code: Select all

addnews();

return;
is that the correct format?

.. and the insults .. please supply a better description would have been more than adequate on a public forum ..