Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2004, 01:37 AM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default CH12 p 404 delete prompt

Hello,
On page 404 CH12, it says that we don't need to ask for confirmation to delete the record because it was already handled with JavaScript promt before. Could you plese tell me where there is a line in the code which deals with Javascript promt. I can't find that.
Thank you,
 
Old June 28th, 2004, 05:45 PM
Authorized User
 
Join Date: May 2004
Location: , , .
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nice catch... It seems that in an earlier version of reviewarticle.php, we used Javascript to capture the click event of the buttons (such as Delete), and validate the user's intentions. That was removed from reviewarticle.php, but we neglected to fix the text on page 404 (isn't it ironic that 404 is the HTTP response code for "not found?"). In this case, you should do one of two things: 1. Include some sort of javascript code in reviewarticle.php to prompt the user before the article gets deleted, or 2. redirect them to a page requesting if they truly want to delete the article.

Also note... if the article is published, the SQL query will work (return no errors), but the article will not actually get deleted. This can be confusing. But if you look at the Delete query, it only works on those articles where is_published=0. This protects published articles from accidentally being deleted. To successfully delete a published article, you first have to retract it, then delete it.

Michael K. Glass
Author, Beginning PHP, Apache, MySQL Web Development
 
Old July 4th, 2004, 04:16 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Could you please give me an example of java script to validate user's intention for deleting and article or if I want to check if the field "title" is typed (otherwise it migth save blank instead of title)?
I tried to do redirect to another page in php, but I found that it's not convenient in cases when I want to reload a page with typed by user input.
For example, when a user compose a new article without a title, I redirect him to page "please enter title", but with redirecting the user loses his typed "body" of the article since it was not saved in db yet and can't be reload. So, I think java scripts are more useful for checking input. Could you please give me some examples of validation java scripts?
Thank you,
 
Old July 4th, 2004, 06:57 PM
Friend of Wrox
 
Join Date: Jun 2004
Location: Fairfield, Iowa, USA.
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am new at php but I will personally redirect to the same page but check for completeness(check that all the required fields are complete)and if something is missing display what was typed using $_POST['field'] but put a note on top of the page with big letter and in red(just to make sure that we make the point) that the title, body, etc is missing. There is actually an example just like this in the book.

Christian

 
Old July 5th, 2004, 05:05 AM
Authorized User
 
Join Date: May 2004
Location: , , .
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There are many ways to do it in Javascript, but this really isn't a Javascript forum. It's not even a PHP forum, but a forum to help users having trouble with code and errata in the book. I suggest you look for a Javascript forum -- a Google search for "Javascript forums" should get you started in the right direction.

Michael K. Glass
Author, Beginning PHP, Apache, MySQL Web Development
 
Old July 5th, 2004, 05:43 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

As Michael pointed out there are several ways to do it. For a form I would use this:

<input type='submit' name='do_action' value='Delete' onclick='javascript: return confirm("Are you sure that you would like to delete the selected records");' />

The onclick event, however can be applied to lots of things. In this case, the onclick event puts out a confirmation dialouge box, which is nothing more than a simple boolean operation. The user clicks OK, the result of the box is TRUE and the form is submitted, if the user clicks CANCEL the result of the box is FALSE and the form is not submitted.

There are general JavaScript forums on P2P too ;) look under the "Web" category and general PHP discussion forums as well, look under "Open Source PHP & Linux".



Regards,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::




Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch12 TextEditor p668 tonyjeffs BOOK: Ivor Horton's Beginning Visual C++ 2005 1 December 15th, 2007 08:03 AM
ch12 sax humayunlalzad BOOK: Beginning XML 3rd Edition 1 May 5th, 2007 10:19 AM
Status 404 for 404 page marun BOOK: Professional Apache Tomcat 0 August 30th, 2005 06:45 AM
Delete Without Prompt MattLeek Excel VBA 3 March 24th, 2004 10:04 AM
Beginners ASP 3.0 Book, Ch12 mramstedt Classic ASP Databases 1 October 4th, 2003 02:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.