Forum Moderators: coopster

Message Too Old, No Replies

Making data not required..

Ugh

         

Acternaweb

4:53 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



I am using a script from a book I have, and following the author's advice in make the application for what I want [book is php and mysql web developmen]. However he has a form that requires data. I am trying to make it so that not all the data is required. I took away the areas that I aren't needed and still get errors.

Here is the code, any help would be great.

<?php

// include function files for this application
require_once('book_sc_fns.php');
session_start();

do_html_header('Adding a book');
if (check_admin_user())
{
if (filled_out($HTTP_POST_VARS))
{
$item_number = $HTTP_POST_VARS['item_number'];
$team = $HTTP_POST_VARS['team'];
$player = $HTTP_POST_VARS['player'];
$catid = $HTTP_POST_VARS['catid'];
$value = $HTTP_POST_VARS['value'];
$description = $HTTP_POST_VARS['description'];

if(insert_book($item_number, $team, $player, $catid, $value, $description))
echo "Book '".stripslashes($team)."' was added to the database.<br />";
else
echo "Book '".stripslashes($team).
"' could not be added to the database.<br />";
}
else
echo 'You have not filled out the form. Please try again.';
do_html_url('admin.php', 'Back to administration menu');
}
else
echo 'You are not playerised to view this page.';

do_html_footer();

?>

willybfriendly

4:56 pm on Dec 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What errors are you getting?

WBF

mogwai

5:00 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



What errors are you getting?

added - Hmmm, I didn't copy I swear :)

Acternaweb

5:10 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



Sorry not a function error, it says
'You have not filled out the form. Please try again

when I leave out info that I don't want to have. For example each item I have doesn't have to have a player's name but it will have to have a team.

volatilegx

6:21 pm on Dec 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this:

<?php

// include function files for this application
require_once('book_sc_fns.php');
session_start();

do_html_header('Adding a book');
if (check_admin_user())
{
if (1)
{
$item_number = $HTTP_POST_VARS['item_number'];
$team = $HTTP_POST_VARS['team'];
$player = $HTTP_POST_VARS['player'];
$catid = $HTTP_POST_VARS['catid'];
$value = $HTTP_POST_VARS['value'];
$description = $HTTP_POST_VARS['description'];

if(insert_book($item_number, $team, $player, $catid, $value, $description))
echo "Book '".stripslashes($team)."' was added to the database.<br />";
else
echo "Book '".stripslashes($team).
"' could not be added to the database.<br />";
}
else
echo 'You have not filled out the form. Please try again.';
do_html_url('admin.php', 'Back to administration menu');
}
else
echo 'You are not playerised to view this page.';

do_html_footer();

?>

That's my quick-and-dirty fix.

Dan

Acternaweb

6:44 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



Thanks that worked, care to explain it a little.

jatar_k

8:16 pm on Dec 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



volatilegx just jumped the checking by changing

if (filled_out($HTTP_POST_VARS))
to
if (1)

I assume the "filled_out" function is to check what has been completed. You could change the filled_out function to only check the fields you want it to but the quixk and dirty works.

Acternaweb

9:06 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



Not sure I follow. What does (1) mean? what if I don't want value to be required, how would that happen.

Also is there a way to display data only if there is something there?

jatar_k

9:10 pm on Dec 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



well that is the quick and dirty as volatile mentioned, it just skips the error checking.

what you need to do is look at the filled_out function. It looks like that is what is checking the fields. I am guessing it is located in htis file

book_sc_fns.php