PHP and MySQL Web Development (4th Edition)

Author: Laura Thomson
4.3
All Stack Overflow 16
This Month Stack Overflow 1

PHP and MySQL Web Development (4th Edition)

4.3

Review Date:

Comments

by anonymous   2017-08-20

Your form is generated via JavaScript, but starting out with a plain HTML form will help you figure the steps out faster. Client side validation via JavaScript is good, but you need server side PHP validation too. You need to beef up on form processing (don't worry, so do I!). You'll catch flack on this site about injection attacks and such. If you can, you may want to investigate some books on web application security. Here are some books that can get you started.

PHP Security

Web Application Security

You need a <form> tag that has the following inside it somewhere.

<form method="post" action="contact.php">

I found your opening <form> tag. Interesting.

<form class="contactform" role="form" method="post" action="#/email.php">

You may want to investigate your action="#/email.php" attribute a bit more. Is that what it's supposed to be?

I usually do something like this (HTML 4.01 inside of PHP. You are using HTML5) (where this line is generated via PHP). Note: Incomplete example.

<form id="contactForm" name="contactForm" enctype="application/x-www-form-urlencoded" accept-charset="UTF-8" action="contact.php" method="post">

</form>

In order for the following code to work, code similar to email.php must be called first so that the values are extracted from the $_POST superglobal array and stored in the variables that you use in contact.php ($name, $email, $human, $to, $subject, $body, $from). Otherwise, your form will, like you say, fail to contact you. This is a logic error, but you can fix it in no time if you find a good example.

No promises, but try this:

<?php

    require('email.php');  //Assuming it is in the same directory as your contact.php

    if ($_POST['submit']) {
        if ($name !== '' && $email !== '') {  //Variables have not been extracted from $_POST yet, as in email.php
            if ($human === '4') {                 
                if (mail ($to, $subject, $body, $from)) { 
                    echo '<p>Your message has been sent!</p>';
            } else { 
                    echo '<p>Something went wrong, go back and try again!</p>'; 
            } 
        } elseif ($_POST['submit'] && $human !== '4') {
            echo '<p>You answered the anti-spam question incorrectly!</p>';
        } else {
            echo '<p>You need to fill in all required fields!!</p>';
        }
    }
?>

I might suggest a few resources to beef up on form processing.

PHP Programming, 3rd Edition

Beginning PHP

PHP, MySQL, & Apache: 5th Edition

PHP Cookbook, 2nd Edition

PHP and MySQL Web Development: 4th Edition

Learning PHP, MySQL, JavaScript, and CSS: Second Edition

Also, there are plenty of free tutorials on the web!

by anonymous   2017-08-20

This is one of the things php is good for.

Since you say you are beginner programmer I'm going to point you to a basic tutorial on checking Databases with sql:

HP 101 (part 8): Databases and Other Animals - Part 1

This tutorial covers all you need:

  • A little SQL
  • MySQL connection
  • Integration with a form.

In general all the PHP 101 series is really good for beginners.

If you prefer a more detailed coverage of the topic then: PHP and MySQL Web Development (4th Edition) is the best beginners book. IMO

by anonymous   2017-08-20

More importantly though, the cookie specification says that browsers need only accept 20 cookies per domain. This limit is increased to 50 by Firefox, and to 30 by Opera, but IE6 and IE7 enforce the limit of 20 cookie per domain. Any cookies beyond this limit will either knock out an older cookie or be ignored/rejected by the browser.

Taken from this author's post

I believe for the unread/read status of forum posts should be done through the database. I could not find an example online, but I have read "PHP and MySQL Web Development (4th Edition)" and they have a section devoted to developing your own forum page. They supply example code and explain the process to get it started.

by anonymous   2017-08-20

No. I'd argue that you should learn PHP first. There are tons of concepts you should be aware before you even consider creating applications using a framework, especially with Yii.

Yii has a higher learning curve than say CodeIgniter and CakePHP. While you might be able to create CRUD applications with them at first, it becomes a problem when you are faced with 'real-world' problems like content scraping, image manipulation, etc.

Learn PHP, create an application (blog/invoice app/inventory system) with vanilla PHP, and you'll be able to get on a framework and learn the framework, not much of the language(some concepts probably). PHP books are useful, when you get enough information from online. Books are good when you want to know different concepts from authors and you'll be fairly sure that the content is correct since they are edited by technical editors compared to unedited content you find online.

Sources I recommend:

Once you get on a framework, you'll now know WHY you even need a framework. WHY you even want to code in MVC. WHY MVC fits you.