error checking + include 'news.php';

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

error checking + include 'news.php';

Post 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
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post 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
-
Last edited by djot on Wed Feb 09, 2005 10:23 pm, edited 2 times in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you're not making any sense Jim_Bo.
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post 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
-
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

djot wrote:Now you can booooooooooo again.
o.O - I never boo'd.. that was Phenom. :)
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post 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
Last edited by Jim_Bo on Wed Feb 09, 2005 11:18 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

watch the insults now..

I would guess that news() displays the news? call it.
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post 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 ..
Post Reply