Page 1 of 1
Request Dump
Posted: Mon Oct 04, 2010 3:48 pm
by elbarf
Someone please help. I have this problem for class. I havent gotten anywheres with it. I have no idea what it's even asking. Can someone please show/explain the solution to me?
create an include file to assist with debugging web forms. The include file should create a table to display the contents of the $_REQUEST autoglobal. The table will have two columns showing each name/value pair. Use the advanced foreach statement syntax to retreive the index and value of each elements of the $_REQUEST array
be sure to use the stripslashes() and htmlentitites() functions before displaying the text in the web poage. Save the document as inc_requestDump.php. Create a second document to test the include file. Save the second document as RequestDump.php.
Re: Request Dump
Posted: Mon Oct 04, 2010 3:56 pm
by pickle
First off - we don't provide homework solutions here. We provide help with homework if you want, but you have to prove you're doing the work. If you have absolutely no idea what it's even asking, then my guess is you either weren't paying attention in class (you should then read through the textbook, or tuck your tail between your legs & go ask your prof), or you just want us to do it for you.
With that said, I have been wrong before so in the interest of giving you the benefit of the doubt:
What is unclear? I realize I have more knowledge in PHP than you, but this seems pretty straightforward to me. Is this for a PHP class or a programming languages class or what? It seems to me that before you got this assignment, the professor should likely have clued you in as to what an include file is, or at least explained the concept behind include files.
$_REQUEST,
stripslashes(), and
htmlentities() are all in the PHP documentation.
Re: Request Dump
Posted: Mon Oct 04, 2010 4:02 pm
by elbarf
Okay, here is my situation. I feel retarded. I was fine in this php class up until now. I'm just confused on what the problem is asking me to do. i don't want you to do it for me. I want it to make sense to me. It's not going to make sense to me on my own. My prof is unavailable at this time, and honestly, i don't want to humble myself asking her for help, as I have been good up until now. It is a php class. I understand what the functions do and what request do, but it is unclear to me what I'm suppose to be doing with them to solve this problem. I would REALLY REALLY appreciate an explanation. I'm having a hard time and this is what I'm doing with my future.
Re: Request Dump
Posted: Mon Oct 04, 2010 4:04 pm
by elbarf
Also, I know what an include file is. I'm just unclear on what I'm printing on the screen.
Re: Request Dump
Posted: Mon Oct 04, 2010 4:21 pm
by pickle
Fair enough - I've had enough brain farts to sympathize. We occasionally get the odd user on these forums asking for homework help without wanting to expend any effort themselves. I wanted to discourage that behaviour - but it doesn't seem that applied here anyway.
It sounds like the professor wants you to build a generic include file you can re-use to help debug forms. The include file is supposed to display the contents of $_REQUEST in a table. You're supposed to use a foreach() loop to loop through the $_REQUEST array, displaying the array keys in one column, and the value in the other.
Of course, do this for the assignment - but a more useful page would be one that displays the contents of $_GET, $_POST, and $_COOKIE separately, as $_REQUEST values can get overwritten. It's pretty much no extra work, and you might get extra credit (or scolded, depending on how the professor deals with students pointing out problems).
stripslashes() is just to ensure what you display on the screen is what was actually posted (and, in fact, you should only run it if magic_quotes are turned on - see
get_magic_quotes_gpc()).
htmlentities() is to ensure whatever the user types in, gets properly displayed on the screen.
Re: Request Dump
Posted: Mon Oct 04, 2010 4:28 pm
by elbarf
This is where I'm lost. What is the form suppose to consist of? Am I suppose to be coding an e mail form. Like what information is the "user" inputting. The problem sounds very vague to me.
Re: Request Dump
Posted: Mon Oct 04, 2010 4:49 pm
by pickle
It doesn't matter what the form consists of - that's partly the point. It could be an email form, it could be a registration form, it could be a "tell me your favourite things" form. The goal is no matter what the form is, your include file can be used to output the contents of $_REQUEST. Using the foreach() loop will allow you to build generic code that can always handle $_REQUEST - regardless of it's contents.
Re: Request Dump
Posted: Mon Oct 04, 2010 8:42 pm
by John Cartwright
Maybe if you took a look at the $_REQUEST global (after you submitted a form or url paremeters) it would show you as to how it is formatted.
I.e.,
Code: Select all
echo '<pre>';
print_r($_REQUEST);
echo '</pre>';
or has Pickle pointed out, it's better to deal with the globals seperately.
Code: Select all
echo '<pre>';
print_r($_GET);
print_r($_POST);
print_r($_COOKIE);
echo '</pre>';
All your professor is asking is to iterate these arrays using
foreach() into a table. Take a look at that url for many examples on iterating arrays.
I guess my next question would be is do you know how to contruct an HTML table?
That's about as much help as I can offer without writting the solution completely for you. It truly is very simple, and you'll see once you complete the task.