0

I am new to PHP. I know a little JavaScript, HTML, MySQL and lots of non-web computer programming.

I know how to create an HTML page with a form, use a button to call an external PHP file (with $_POST) which sends an email and records that forms data (names and email addresses) into a MySQL database.

Now, I'd like to create a new HTML page that calls an external PHP file (so the code is hidden) that will return the MySQL data (names and email addresses) for display on that existing HTML page (with all its CSS formatting and menus). In otherwise, I'd like to modify an existing HTML page with data (but hide the PHP code in an external file).

If this can be done (I'm new to this), can some please help by giving me at least the general idea so that I can build upon it. The textbooks that I've flipped through simply explain how to "echo" data back to the screen (a blank screen) with a .php extension in the address bar.

Thank you very much for your time and any help. I appreciate it!

6
  • 3
    It would probably be wise to follow some basic tutorials (Google is your friend), as StackOverflow tends to be more about solving specific issues rather than providing lengthy tutorials. For example, a tutorial would resolve the fact that there's no need to have both an HTML and PHP page (the PHP code just outputs the HTML), etc. As a start, the PHP site has it's own tutorial which should at least clue you into some of the basics. Commented Aug 7, 2013 at 18:55
  • I have spent the last 3 days flipping through basic tutorials (with Google), but know have explained it. I only want an HTML page (but I believe that I need PHP code (that runs on the server side) to get the data and return it to the HTML page that initiated that PHP). I have years of experience with C and LabVIEW, but that kind of application structure and data flow is different. Commented Aug 7, 2013 at 19:05
  • 1
    In that case, answers such as @Homer6's may be more up your street. Incidentally, there's no need to attempt to "hide" the PHP code as it's parsed by the web server to produce the HTML and hence not exposed to the end user. (Unless the server is very, very, ill.) Commented Aug 7, 2013 at 19:08
  • Does that mean that, in this case: Commented Aug 7, 2013 at 19:19
  • 1
    Anything inside <?php ... ?> should be hidden if you've properly configured your server. Otherwise all bets are off. Commented Aug 7, 2013 at 19:40

1 Answer 1

1

Since you already have the html to echo part, you'll just need to plug it into the database.

Using a good ORM can help with this. For PHP, I recommend starting with Propel:

http://propelorm.org/

Once you get a bit more comfortable with that, you might want to try using a PHP framework, like Symfony, to help you structure the project in a more uniform way. However, there are many other PHP frameworks out there, so try to evaluate the top ones before settling on a favorite.

Furthermore, the examples provided in PHP framework documentations will guide you through many of the common solutions (as a framework is just a toolkit built by people who have had to solve such problems over and over).

For example, here is the cookbook for symfony that outlines many solutions to common issues.

Sign up to request clarification or add additional context in comments.

7 Comments

You don't think an ORM framework might be a little bit ambitious at this stage? :-) (That said, ignoring the hugely out of date (yet still widespread) use of mysql_* will be a definite benefit.)
No. ORMs are nothing special. No need to talk down to a person who is new, they will set their own limits based on their comfort. Different users will choose different solutions. You should post the mysql_ answer so that this user can see that approach as well. However, I'd recommend this approach. I believe it's easier to use and is a more productive tool that can be used again and again.
A framework seems like a good idea. Since, I'm trying to learn web app development, I wonder if I should go down a different path. Perhaps Microsoft Visual Studio (but I'm told the learning curve is long) or perhaps Ruby on Rails (a different language and a framework, but that's ok).
@middaparka A framework is essential to learning how to develop applications properly. You know what's ambitious? Learning how to do everything by yourself and having to re-make the same mistakes as everyone else. Leaning on a framework to help you implement the basics correctly, securely, and in a maintainable structure is not something to be ashamed. Use the correct tool for the job, and for web applications, a popular web framework is the only practical way to get started.
If you're considering a different path, I'd highly recommend meteor.com
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.