Jump to content

included files and $_POST variables (thinking error)


rghollenbeck
Go to solution Solved by rghollenbeck,

Recommended Posts

I have an attached header (database.php) file which does all the connecting to the MySQL database and has all the db connection variables, etc., and does all the logical heavy lifting.  But the form on the previous page (quiz_selector.php) doesn't point to database.php but to the file it's included in (quiz.php).

 

Should that make a difference?  Database.php never gets the $_POST data but the file it is included in (quiz.php) gets the data. 

 

I'm wondering if I shouldn't just send the form data directly to database.php.  Nah.  That doesn't seem like the right solution. How do I get the data into database.php?

 

Category_selector.php's form action is set to quiz.php. Quiz.php includes database.php.  Database.php does all the work but quiz.php gets all the input from the form on category_selector.php.

 

(I realize I'm asking the same question twice or three times in the same message. Sorry.  I'm trying to make sure I clearly state my problem.)

 

I could attach my code here to this thread (I will include relevant parts of the code if asked to do so,) but my code does not seem to be the problem.    I believe the problem is that my thinking is all screwed up.  If all the logic is done in database.php, how do I get the data there from quiz_selector.php when I am calling quiz.php and database.php is only an included file?  (How do I rewrite my code when it's my brain that needs rewiring? But I digress.)

 

This quiz program is in the VERY early stages of development.  I'm thinking about including yet a third file.  I could open and close the database in database.php, and then move all the logical operations to another included file. Seems simpler. Even then, the same question about where to send the $_POST data would still apply.

 

P.S. I'm using PDO in case that makes any difference.

 

Thanks to all.

Edited by rghollenbeck
Link to comment
Share on other sites

Posting this topic may have been premature. I was able to get the database.php file to read the $_POST['categoryname'] variable that was sent to quiz.php, so I don't know what I was doing wrong before. I don't know how to delete this post. I'm still testing.  Maybe I will still need this question answered, but it looks at the moment as if it may be solved.  Oops!  I haven't yet attempted to do any logic; I only echoed the variable successfully.

Edited by rghollenbeck
Link to comment
Share on other sites

  • Solution

Posting this topic was premature. I was able to get the database.php file to work right.  I am very sorry for the time waster.  It was inexperienced newbie stuff like forgetting to put an underscore on $_SESSION['categoryname'] and stuff like that.

 

I have to do at least two things in the future:

  1. double check my work before posting to this forum
  2. triple check my work before posting to this forum

 

Sorry! and thanks for all the great answers you folks have helped me with in the past.  When I get better at this, I hope to return the favor on this forum.

Edited by rghollenbeck
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.