?
Solved

Use data to Populate DB Tables and Another Form in PHP

Posted on 2013-06-25
5
Medium Priority
?
189 Views
Last Modified: 2013-06-26
I have a form that uses PHP to populate tables in a database. I want to use the same data to populate a printable form at the same time the tables are populated. I want this to be one step for users. When they click the "submit" button, I want the data sent to the database and to the printable form.

I am in the process of creating the printable form in the same php file I sent the data to the database. Is this the best way or is there a better way? If there is a better way, please give me some tips. Thanks in advance.
0
Comment
Question by:wayneray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 1000 total points
ID: 39276859
That's pretty much the only way because that's when you have the data available to you.  I suppose you could retrieve it back from the database but that would take a little longer and it would still be the data you already have.  

I am about to do one that way but that's partly because I need to be able to display it later also.  So I'm going to create the printable form, send a copy to my customer and save a copy in the database.  That allows my customer to display it to their customer if and when they need to.
0
 

Author Comment

by:wayneray
ID: 39277671
Which is easier, populate the printable form first then send data to the database or does it matter?
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39278904
It doesn't matter except that if you are calculating or generating some data, you have to do that before you can use it.  I would normally assign POST data to variables and do any filtering needed, do all the calculations that were needed, create the email or document, email it, and then put it in the database for later use. The last two, email and database are usually interchangeable because you have already made all the changes to the data by then.
0
 

Author Closing Comment

by:wayneray
ID: 39278937
Thanks for your help. I asked a stupid question this morning. Not awake I guess. All is working fine. I have to submit to the database first to get info needed to populate other tables.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39278999
You're welcome, glad to help and thanks for the points.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question