Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



  1. Hello, I have studied the method presented in chapter 10 for viewing, editing, and deleting users. However, I am a bit concerned about when a user clicks the link to edit or delete, the user ID is passed via the URL to another page. Ex here: [from view_users.php] <td align="left"><a href="edit_user.php?z=' . $id . '">Edit</a></td> <td align="left"><a href="delete_user.php?z=' .$id . '">Delete</a></td> I have found that I can simply change that ID value and perform an edit or delete on another user. This is a concern especially if that user is not authorized to make that edit or deletion. I believe this example is meant for an admin, but I want to pass this functionality a level below to a group leader that can manage their users. My question for the forum is how could this method be made more secure? I've been racking my brain on this can and can't seem to figure out the best approach. I know passing session variables to the edit and delete scrips would be most secure, but how can I bind the selection of a user (and their respective ID) from a row of names to a specific session variable and then call on that session variable from the edit and delete.php scripts to perform the edit or deletion? I appreciate any thoughts. Thanks,
  2. HI all, I am in chapter six at the end when we are building the FOR loop. I am having a problem with netbeans rendering the php in the html. Is anyone else having this problem. I have tried the following, I have restarted Netbeans. I have commented out the section and retyped it. I have copied another php section from handle_reg.php and it does not render either. I have cut out the php script, saved, restarted netbeans, and retyped the script. I have gone character by character comparing syntax with the book, everything is as the book has it. here is the code I am writing. <p>Date of Birth: <select name="month"> <option value="">Month</option> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select name="day"> <option value="">Day</option> <?php <--this is marked in Netbeans as a misspelled word. Also this whole section is not color coded as other php scripts in the same project are. for ($i = 1; $i <= 31; $i++) { print "<option value=\"$i\">$i</option>\n"; } ?> </select> <input type="text" name="year" value="YYYY" size="4"/> </p> When I run this in the browser (chrome latest version) the drop down only shows "Day" as an option, When I copy the Select statement in question to handle_reg.php and run it in the browser it rruns just fine i see a drop down with 31 numbers. Is there a setting in netbeans that is not allowing php to render inside html? I don't think so because it works in every other page? I am stumped! Any ideas?
  3. Hello, I have been looking through the posts and the two books - Effortless E-Commerce and PHP and MySql for Dynamic Websites but have not found any information on limiting the number of characters that a user can type into a text area or a counter that shows the user how many characters they have typed so far. Can this be done in PHP or is this just a javascipt thing? Marie
  4. Hi, I have a couple of questions regarding PHP and JavaScript. 1) What I would like to know is once I do a SELECT COUNT Query I want to then do a For-Loop to out put the same number of input boxes but with a PHP variable as the value so that JavaScript could pick that value up, Is that possible to be done, I mean can JavaScript/JQuery read PHP variables. They will be Hidden Input boxes as well. PHP 6 MySQL 5.2 HTML5 CSS3 Chrome / IE 8
  5. Hello, I have been attempting a "Welcome Back" type message using a session variable in order to give the user the idea that they have actually logged in. I also understand that his is done with cookies. However, when I put the "user_id" session variable code on my page, I get the registrant's user id so that makes me think I am using the right code, but that is not what I want the user or the world to see. When I use the same code and insert "username", I don't get the registrant's username I get MY actually username for the database. I am basing my test website on the Knowledge of Power site and would like this kind of thing to come up on all pages that the user might pull up as they go through the site. I am still learning PHP and it seems like there are many different ways of writing this language. Thanks, Marie
  6. My registration form will not accept any name with a space, hyphen or apostrophe, such as O'Meara or Mary-Lou. The form tells me to "Please enter your first name or last name or username - whichever applies. When I take the space, hyphen, or apostrophe out then the form will submit. I am using the code from the Knowledge is Power sight.<?php // Check for a form submission: if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Check for a first name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $_POST['first_name'])) { $fn = mysqli_real_escape_string ($connect, $_POST['first_name']); } else { $reg_errors['first_name'] = 'Please enter your first name!'; } // Check for a last name: if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $_POST['last_name'])) { $ln = mysqli_real_escape_string ($connect, $_POST['last_name']); } else { $reg_errors['last_name'] = 'Please enter your last name!'; } // Check for a username: if (preg_match ('/^[A-Z0-9]{2,30}$/i', $_POST['username'])) { $u = mysqli_real_escape_string ($connect, $_POST['username']); } else { $reg_errors['username'] = 'Please enter a desired name!'; } Hoping that someone can shed some light on this problem. Thanks, Marie
  7. Hello, It seems when I try to add some space between the form field and any visible wording, I lose the form's "stickiness" and also the hints to tell people to fill out a certain field, if it has been done incorrectly. I would like my forms to look nice but can't seem to override this in CSS or in the php code. Marie.
  8. An error occurred during a connection to www.mydomain.co.uk SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long) I am stuck on chapter 6. After signing into paypal sandbox, using the buyer account I created & then clicking the 'go back to my site button,' I got the following error above. How do I solve this please?
  9. I've been testing code against the RCs of PHP 5.4 for about a month and realised that the official stable version was released in the last 24 hours. Liking it a lot: especially the short array syntax, built in server and traits. Nice to see register globals and magic quotes gone too. Can't believe how tedious writing array in 5.3 has already become. Anyway, I thought I'd just post this up just in case anyone had missed it: http://php.net/releases/5_4_0.php
  10. I am having trouble getting my scripts to work when it coes to sessions without cookies. I have amended the login.php script as per the book and then amended the remaining scripts header.html, loggedin.php and logout.php as described in the book but find when entering a valid email address and password I am returned straight to the index.php page. Please can you assist me in understanding what I am doing wrong, I have been trying to work through it and resolve it my self for the last 2 days. I have MySQL Server 5.5, php 5.3.6 and Windows 7 Home 64bit running on my own computer using the localhost server. Please find attached my scripts. Login.php <?php # Script 9.16 - login.php // Send nothing to the browser before session_start() line! // Check if the form has been submitted. if (isset($_POST['submitted'])) { require_once ('../secure/mysql_connect.php'); // Connect to the db. $errors = array(); // Initialise error array. // Check for an email address. if (empty($_POST['email'])) { $errors[] = 'You forgot to enter an email address.'; } else { $e = escape_data($_POST['email']); } // Check for a password. if (empty($_POST['password'])) { $errors[] = 'You forgot to enter a password.'; } else { $p = escape_data($_POST['password']); } if (empty($errors)) { // If everything is OK. /* Retrieve the user_id and first name for the email/password combination */ $query = "SELECT user_id, first_name FROM users WHERE email='$e' AND password=SHA('$p')"; $result = @mysql_query($query); // Run the query. $row = mysql_fetch_array ($result, MYSQL_NUM); // Return a record, if applicable. if ($row) { // A record was pulled from the database. // Set the session data and redirect. session_name ('YourVisitID'); ini_set('session.use_cookies', 0); // Don't use cookies. session_start(); $_SESSION['user_id'] = $row[0]; $_SESSION['first_name'] = $row[1]; // Redirect the user to the loggedin.php page. // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\')) { $url = substr($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/loggedin.php?' . SID; // Add the session name & ID. header("Location: $url"); exit(); // Quit the script. } else { // No record matched the query. $errors[] = 'The email address and password entered do not match those on file.'; // Public message. $errors[] = mysql_error() . '<br /><br />Query: ' . $query; // Debugging message. } } // End of if(empty($errors)) if. mysql_close(); // Close the database connection. } else { // Form has not been submitted. $errors = NULL; } // End of main submit conditional. // Begin the page now. $page_title = 'Login'; include('./includes/header.html'); if (!empty($errors)) { // Print any error messages. echo '<h1 id="mainhead">Error!</h1> <p class="error">The following error(s) occurred:<br />'; foreach ($errors as $msg) { // Print each error. echo "- $msg<br />\n"; } echo '</p><p>Please try again.</p>'; } // Create the form. ?> <h2>Login</h2> <form action="login.php" method="post"> <p>Email Address: <input type="text" name="email" size="20" maxlenght="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>"/></p> <p>Password: <input type="password" name="password" size="20" maxlength="20"/></p> <p><input type="submit" name="submit" value="Login"/></p> <p><input type="hidden" name="submitted" value="TRUE"/> </form> <?php include ('./includes/footer.html'); ?> Header.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...ransitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title><?php echo $page_title; ?></title> <style type="text/css" media ="all">@import "./includes/layout.css";</style> </head> <body> <div id="wrapper"><!-- Goes with the CSS layout. --> <div id="content"><!-- Goes with the CSS layout. --> <div id="nav"><!-- Links section --> <h3>Menu</h3> <ul> <li class="navtop"><a href="index.php?<?php SID; ?>" title="Go to Home Page">Home</a></li> <li><a href="register.php" title="Register?<?php SID; ?>">Register</a></li> <li><?php // Create a login/logout link. if ((isset($_SESSION['user_id'])) && (!strpos($_SERVER['PHP_SELF'], 'logout.php'))) { echo '<a href="logout.php?<?php SID; ?>" title="Logout">Logout</a>'; } else { echo '<a href="login.php?<?php SID; ?>" title="Login">Login</a>'; } ?></li> </ul> </div> <!-- Script 9.8 - header.html --> <!-- Start of page specific content --> Loggedin.php <?php # Script 9.17 - loggedin.php # User is redirected here from login.php. session_name ('YourVisitID'); ini_set('session.use_cookies', 0); session_start(); // Start the session. // If no session value is present redirect the user. if(!isset($_SESSION['user_id'])) { // Start defining the url. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) =='\\')) { $url = substr($urll, 0, -1); // Chop off the slash. } $url .= '/index.php'; // Add the page. header ("Location: $url"); exit(); // Quit the script. } // Set the page title and include the HTML header. $page_title = 'Logged In!'; include ('./includes/header.html'); // Print a customised message. echo "<h1>Logged In!</h1> <p>You are now logged in, {$_SESSION['first_name']}!</p> <p><br /><br /></p>"; include ('./includes/footer.html'); ?> logout.php <?php # Script 9.18 - logout.php // This page lets the user log out. session_name('YourVisitID'); ini_set('session.use_cookies', 0); session_start(); // Access the existing session. // If no cookie is present, redirect the user. if(!isset($_SESSION['user_id'])) { //Start defining the url. $url = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\')) { $url = substr($url, 0, -1); // Chop of the slash. } $url .= '/index.php'; // Add the page. header("Location, $url"); exit(); } else { // Cancell the session. $_SESSION = array(); // Destroy the variables. session_destroy(); // Destroy the session itself. } // Set the page title and include the HTML header. $page_title = 'Logged Out!'; include ('./includes/header.html'); // Print a customised message. echo "<h1>Logged Out!</h1> <p>You are now logged out!</p> <p><br /><br /></p>"; include ('./includes/footer.html'); ?>
  11. Hey Guys, I learned everything I know from Larry's books, but this question is not directly from any of his books. But I really need some help! I've set up a script to listen for IPN from paypal. I see the IPN activity in my paypal IPN history. The listener script that I set up is supposed to change one row in my database (I'm adding a user_meta value to a wordpress user to flag him as a premium user). The database update is not happening. When I point my browser to the page where the ipn script is hosted, this is the error message I see: web browser to the page on which my ipn script is located, I get this php error message: Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://www.paypal.com:443 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in /home/adven/avclients.com/belovedsamoa/latest/ipn.php on line 20 Does anyone have any advice at all? What more do you need in order to help me? phpinfo() output below: In full: http://avclients.com...est/phpinfo.php The highlights: PHP Version 5.3.6 SSL Version OpenSSL/0.9.8b System Linux webserver.adventuresdesign.com 2.6.18-164.11.1.el5xen #1 SMP Wed Jan 20 08:06:04 EST 2010 x86_64 Build Date Mar 23 2011 12:20:27 Configure Command './configure' '--disable-fileinfo' '--disable-phar' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-libxml' '--enable-magic-quotes' '--enable-mbstring' '--enable-pdo=shared' '--enable-sockets' '--prefix=/usr' '--with-curl=/opt/curlssl/' '--with-curlwrappers' '--with-gd' '--with-gettext' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libdir=lib64' '--with-libxml-dir=/opt/xml2/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-pcre-regex=/opt/pcre' '--with-pdo-mysql=shared' '--with-pdo-sqlite=shared' '--with-pic' '--with-png-dir=/usr' '--with-sqlite=shared' '--with-xpm-dir=/usr' '--with-zlib' '--with-zlib-dir=/usr'
  12. I developed on my Windows XP machine with a Wamp server and developed in Flash Builder 4. While I was developing and using data services - when prompted by Flash Builder I let it install the Zend Framework. Now I need to deploy a Flex 4 web application developed in Flash Builder 4 on an Ubuntu Linux production server which has MySQL and php already installed. Am I supposed to install Zend on the Linux server? The Adobe Help documentation is confusing... According to: http://help.adobe.com/en_US/flashbuilder/using/WSe4e4b720da9dedb5-13a250c812e8e9b5533-7ff9.html : "(PHP server projects only) For PHP projects, perform these additional steps: Install the Zend framework on the server. See Installing Zend Framework. ". However, according to http://help.adobe.com/en_US/flex/accessingdata/WSbde04e3d3e6474c45b672e6c12574edcc5e-8000.html : For productions servers, Adobe recommends that you move the ZendFramework folder outside the web root. Update the zend_path variable defined in amf_config.ini. If the zend_path variable is commented out, uncomment the zend_path variable. Specify the location of your Zend Framework installation. If Flash Builder installed the Zend Framework, check the following: The location of the web root folder Flash Builder installs the Zend Framework in the project’s web root folder. Check the location of the web root folder. Select Project > Properties> Flex Server. Ensure that the web server is configured to use PHP. Examine the zend_path variable in amf_config.ini. amf_config.ini is in the project output folder. Thanks for the help!
  13. First off, what a well written technical book! Thanks Larry. I'm working on a project that currently uses JavaScript validation. The page will have PHP functionality later, but after reading chapter 6's validation examples, I got to thinking . . . Can I have slicker AJAX style same page validation using PHP? This would put the error messages in the same page after form field completion but before submission. I saw an example elsewhere that essentially points the action to the same page, but it used a lot of "include" scripting. The validation scripting in the book is so simple, yet the JavaScript currently being used in my project seems so unnecessarily clunky. So, in short, what is the easiest way to augment the validation example in the book for same page validation? Would it be more efficient than AJAX validation?
  14. No matter what I do the length of my text area does not change. I can change the depth. I am testing my site on three different browsers and it comes out with either a scroll bar or a tab that the user can pull to a different length. I would like a set box so that the user can see what they type and know how much space they have to use. My text areas are about 1-1/2" wide and I would like it to be 4" wide. I do not see any CSS that would be overriding it. This is the code from the Knowledge is Power web site in the forms_function.inc.php. I have changed the depth to 2 columns. I have tried several different configurations of code but it does not change. // Start creating the textarea: echo '<textarea name="' . $name . '" id="' . $name . '" rows="2" cols="150"'; Thank you, Marie
  • Create New...