Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'sticky form'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 3 results

  1. Ok, so posted on Ch. 13 Pursue earlier about making the login form sticky which I had great help getting resolved. Then when I get down the part where I need to make add_quote.php sticky, I have made the text area and source sticky but am having a really hard time trying to figure out how to get the checkbox to be sticky as well. I'm not even 100% sure if that's something that I'm even supposed to try to do for that part but it's an intriguing problem that I've run into and I can definitely see where knowing how to make a checkbox be sticky can be helpful in the future. I've searched all over the place for the past few days and tried countless times to get it to work. Most of the threads I've come across never give a straight answer on how to do this or it's like the original question never gets answered and the thread just kind of dies. Anyone out there know of a way to do this? Here is the code that I have and most of the variations I've tried always posts the favorite, but it just won't remain sticky. The red section and value for the checkbox at the bottom is the latest that I've come across that still doesn't seem to work. <?php // Script 13.7 - add_quote.php /* This script adds a quote. */ // Define a page title and include the header: define('TITLE', 'Add a Quote'); include('templates/header.html'); print '<h2>Add a Quotation</h2>'; // Restrict Access to administrators only: if (!is_administrator()) { print '<h2>Access Denied!</h2><p class="error">You do not have permission to access this page.</p>'; include('templates/footer.html'); exit(); } // Check for a form submission: if($_SERVER['REQUEST_METHOD'] =='POST') { // Handle the form. if (!empty($_POST['quote']) && !empty($_POST['source'])) { // Need the database connection: include('includes/mysql_connect.php'); // Prepare the values for storing: $quote = mysql_real_escape_string(trim(strip_tags($_POST['quote'])), $dbc); $source = mysql_real_escape_string(trim(strip_tags($_POST['source'])), $dbc); // Create the "favorite" value: if (isset($_POST['favorite'])) { $favorite = 1; } else { $favorite = 0; } $query = "INSERT INTO quotes (quote, source, favorite) VALUES ('$quote', '$source', '$favorite')"; $r = mysql_query($query, $dbc); if (mysql_affected_rows($dbc) == 1) { // Print a message: print '<p>Your quotation has been stored.</p>'; } else { print '<p class = "error">Could not store the quote because: <br />' . mysql_error($dbc) . '.</p><p>The query being run was: ' .$query . '</p>'; } // Close the connection: mysql_close($dbc); } else { // Failed to enter a quotation. print '<p class = "error">Please enter a quotation and a source!</p>'; } } // End of submitted IF. // Leave PHP and display the form: ?> <form action="add_quote.php" method="post"> <p><label>Quote <textarea name="quote" rows="5" cols="30" ><?php if(isset($_POST['quote'])) {print htmlspecialchars($_POST['quote']); } ?></textarea></label></p> <p><label>Source <input type="text" name="source" value="<?php if(isset($_POST['source'])) {print htmlspecialchars($_POST['source']); } ?>"/></label></p> <p><label>Is this a favorite? <input type="checkbox" name="favorite" value="<?php if(isset($_POST['favorite']) && ($_POST['favorite'] == 1)) print 'checked = "checked"'; ?>" /></label></p> <p><input type="submit" name="submit" value="Add This Quote!" /></p> </form> <?php include('templates/footer.html'); ?> At this point, I wouldn't be surprised if what I have is way off but I'm still trying and have hit a wall for sure. Thanks in advance for any help or suggestions. Scatz
  2. Hi all, I bought this book 2 weeks ago and have starting reading it a few days back. I am having a problem. I'm doing the review of the 2nd chapter but I modified the tasks a bit and I am in a quagmire with a function inside a function. The problem is that I want the "checked" to be contained inside the <input checked="checked"> but instead it keeps reverting back to before the entire html output. Relevant PHP // function to control which radio button will be checked depending on the value entered by user function ifstatement1 ($value,$id) { if ( ($value < 5.7) && ($id==1) // checked first radio button OR (($value>5.7) && ($value <6.4)) && ($id==2) // checked second radio button OR ($value > 6.4 ) && ($id==3) // checked third radio button ) { echo "checked"; } } // Create radio button function function create_radio ($id, $name, $value, $description){ echo '<p><input type="radio" id="'.$id.'" name="'.$name.'" value="'.$value.'" checked="'. ifstatement1 ($value,$id).'" > '. $description .'</p>'; } Any help will be appreciated, Thanks
  3. Hi, first of all....this is a great book! Ok now to my question. I have created a HTML form in which there is a selection box generated by a php foreach loop: <?php //Array containing option values $options=array('Architecture','Interior Design','Dimensional Surveys','Party Wall Surveyors','In-house visualizations','CDM'); //Foreach loop to insert values into HTML echo'<select class="formInputText"name="selService[]"id="selService"multiple="multiple">'; foreach($options as $service){ echo"<option value=\"$service\">$service</option>\n"; } //close HTML select tag echo'</select>'; ?> If I were to make a sticky form using a conventionally generated HTML select box (i.e. typr it all out myself rather than let php do it, I would do something like the following: <option value="Architect"><?php if(isset($_POST['Architect'])echo 'selected="selected"?>Architect</option> In the form I have created with php, I was thinking that the following would work: echo"<option value=\"$service\">if(isset($_POST[$service]))echo\'selected\'="\selected"\</option>\n"; but it doesn't. I have tried several variations of this (i.e. with single and double quotes, etc...) but to no avail. Would you be able to point me in the right direction? Thanks Jonathan ?>
×
×
  • Create New...