Jump to content

Search the Community

Showing results for tags 'form validation'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 9 results

  1. Hi there. My problem is quite simple, but carries lots of questions of why the hell is this happening. I'm new at PHP but I'm familiar with the syntax, since It's been 3 years since I code in C, 1 in Java and half year in JS (with HTML and CSS of course). I was creating a page where I could validate a HTML form using PHP script, it was going everything allright, until I couldn't use the data that was going to the $_POST array. I tested it on some other file and It was like the server just didn't allowed me to do it so. I searched around on internet and I found the print_r() function, which shows the data as an associative array in $_POST, like this: array(KeyName => ValueName). Check the code and please, help me find why is this happening. I'm brazillian and all I know about english came from netflix, so i'm sorry if I wrote anything wrong. Thanks S&Z <!DOCTYPE html> <html lang = "pt-br" > <head> <title> Formulário </title> <meta charset="utf-8"> </head> <body> <form method = "POST" action = "<?php htmlspecialchars($_SERVER["PHP_SELF"]);?>" autocomplete = "off"> Nome: <br> <input type = "text" name = "Name" placeholder = "Ex: Guilherme" required autofocus> <?php if($_SERVER["REQUEST_METHOD"] == $_POST){ echo $_POST["Name"]; } ?> <br><br> <input type = "submit" value = "Enviar"> </form> <?php print_r($_POST); ?> </body> </html>
  2. What is the best way for form validation before inserting the data into db? ( Let's say the field is textarea which is the "Bio" part of the user & html tags are allowed) According to w3schools, this may be enough; function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } But some say " mysqli_real_escape_string " is needed also, so should i add that one too? function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); $data = mysqli_real_escape_string($dblink,$data); return $data; } So as a newbie, I m wondering the best and most secure way for validation before inserting the data into db. Thanks in advance.
  3. Hi everyone Im having a nightmare with javascript again grrrr, I'm just not great with javascript / jquery so basically I have a table with inputs to create an invoice, the reason im using javascript to post the form is because i have to allow for infinite items to be added into the database using json stringify as an array, the problem I have is im trying to force that atleast 1 item be added to the table before posting the data. I am using bootstrap and this hasn't been a problem for all of my other forms because i can just add required to the input but because i have to do this one differently using an a href button This form just wont validate (but it will post the data to the php script) so here is my code: Table with inputs: <tbody style="" class="item ui-sortable-handle"> <tr> <td rowspan="2" class="td-icon"> <i class="glyphicon glyphicon-resize-vertical cursor-move"></i> </td> <td class="td-text"> <input type="hidden" name="invoice_id" value="<?php echo $invoiceNo;?>"> <input type="hidden" name="item_id" value> <div class="input-group"> <span class="input-group-addon">Item</span> <input type="text" name="item_name" class="input-sm form-control" required> </div> </td> <td class="td-amount td-quantity"> <div class="input-group"> <span class="input-group-addon">Quantity</span> <input type="text" name="item_quantity" class="input-sm form-control amount"> </div> </td> <td class="td-amount"> <div class="input-group"> <span class="input-group-addon">Price</span> <input type="text" name="item_price" class="input-sm form-control amount"> </div> </td> <td class="td-amount"> <div class="input-group"> <span class="input-group-addon">Item Discount</span> <input type="text" name="item_discount_amount" class="input-sm form-control amount" data-toggle="tooltip" data-placement="bottom" title data-original-title="£ Per Item"> </div> </td> <td class="td-amount"> <div class="input-group"> <span class="input-group-addon">Tax Rate</span> <select name="item_tax_rate_id" class="form-control input-sm"> <?php //this section may update based upon selections but for now We have none echo "<option value='0'>None</option>"; ?> </select> </div> </td> <td class="td-icon text-right td-vert-middle"></td> </tr> <tr> <td class="td-textarea"> <div class="input-group"> <span class="input-group-addon">Description</span> <textarea name="item_description" class="input-sm form-control"></textarea> </div> </td> <td colspan="2" class="td-admount td-vert-middle"> <span>Subtotal</span> <br> <span name="subtotal" class="amount"></span> </td> <td class="td-amount td-vert-middle"> <span>Discount</span> <br> <span name="item_discount_total" class="amount"></span> </td> <td class="td-amount td-vert-middle"> <span>Tax</span> <br> <span name="item_tax_total" class="amount"></span> </td> <td class="td-amount td-vert-middle"> <span>Total</span> <br> <span name="item_total" class="amount"></span> </td> </tr> </tbody> </table> </form> </div> </div> <!-- End of items Tables--> The Save button at the top of the page before the table: <a href="#" class="btn btn-success ajax-loader" id="btn_save_invoice"> And lastly my attempt at the javascript / jquery / ajax: <script type="text/javascript"> $('#btn_save_invoice').click(function () { $('#item_form').validate({ rules: { item_name:{ required: true, message: 'This is required' } }, }); var items = []; var item_order = 1; $('table tbody.item').each(function () { var row = {}; $(this).find('input,select,textarea').each(function () { if ($(this).is(':checkbox')) { row[$(this).attr('name')] = $(this).is(':checked'); } else { row[$(this).attr('name')] = $(this).val(); } }); row['item_order'] = item_order; item_order++; items.push(row); }); $.post("<?php echo url()."Clients/invoice_ajax.php"; ?>", { invoice_id: <?php echo $invoice_id; ?>, invoice_number: $('#invoice_number').val(), invoice_date_created: $('#invoice_date_created').val(), invoice_date_due: $('#invoice_date_due').val(), invoice_status_id: $('#invoice_status_id').val(), invoice_password: $('#invoice_password').val(), items: JSON.stringify(items), invoice_discount_amount: $('#invoice_discount_amount').val(), invoice_discount_percent: $('#invoice_discount_percent').val(), invoice_terms: $('#invoice_terms').val(), custom: $('input[name^=custom]').serializeArray(), payment_method: $('#payment_method').val() }, function (data) { var response = JSON.parse(data); if (response.success == '1') { window.location = "<?php echo url()."Clients/invoice_ajax.php"; ?>/" + <?php echo $invoice_id; ?>; } else { $('#fullpage-loader').hide(); $('.control-group').removeClass('has-error'); $('div.alert[class*="alert-"]').remove(); var resp_errors = response.validation_errors, all_resp_errors = ''; for (var key in resp_errors) { $('#' + key).parent().addClass('has-error'); all_resp_errors += resp_errors[key]; } $('#invoice_form').prepend('<div class="alert alert-danger">' + all_resp_errors + '</div>'); } }); }); </script> Please bare in mind the actual posting section of the form Works perfectly! the only issue is the inputs will not validate before post. here is what the page looks like (i have highlighted the parts that I am referring to in the post: I really am thankful for all the help i get, a huge thank you in advance to anyone who helps with this.
  4. Hi all, PHP newbie here. I've been trying to integrate Gravity Forms with Gravity View's Import Entries from CSV plugin. Unfortunately, it needs a bit of tweaking to get everything connected properly. I used a code snippet from David at Gravity Whiz, (HERE) that gets integrated into my Wordpress site's functions.php file, and have been trying to customize to to suit my needs. From what I understand in looking at the code, the only bit I need to tweak (I think) is the bottom portion: # Configuration new GW_Value_Exists_Validation( array( 'target_form_id' => 1, 'target_field_id' => 3, 'source_form_id' => '/RSVPcodes.csv', 'source_field_id' => 'rsvp', 'validation_message' => 'Hey! Don\'t be a villain! Provide a legit RSVP code to reserve your spot at the Smackdown.' ) ); My main question here: how to get the validation code to see the database that I've uploaded via the Import Entries plugin? I know ignorance is making me miss something that should be pretty simple. Right now, I've got it to validate a test word that I know is not in my database, and also a code that I know is in the database. It's coming back with both items as not valid. The end result will be a RSVP form that will be used to accept RSVPs only from people who have an RSVP code from their invitation, a lot like a license key validation system. The live site (and form I'm trying to tweak) is HERE. Thanks in advance for any help.
  5. Hey, I have created a contact us form which works nicely with my site, however I have some backup PHP validation code, which all works apart from the last name section, how can I set it up to it checks to see if there is a first name and a last, maybe even another name? This is what I have so far and it only works if you put in a first name and nothing else: $string_exp = "/^[A-Za-z.'-]+\$/"; if(!preg_match($string_exp, $name)) { $error_message .= 'The Name you entered does not appear to be valid.<br/>'; } Thank you
  6. Hey everyone, I have a page that I created for users to select certain products to reserve. Each product is listed and a form is created using a while loop. For some of the products, the user selects to use it wet or dry using a drop down menu. I also have a javascript function that validates the forms that give the option to select to use the product wet or dry, so that if the user does not select one of these options, a popup will apear prompting them to do so. The problem that I'm having is that ON ALL EXCEPT THE FIRST FORM/PRODUCT PRODUCED FROM THE WHILE LOOP, the form validation produces a popup prompting the user to select the wet or dry option even if the option is selected. THE FIRST FORM VALIDATION ON THE PAGE WORKS AS IT SHOULD. I'm obviously doing something wrong, but I have no idea what. I've worked on it for two days so now I'm asking for help. My code is listed below. Thanks in advance. PHP code: <?php $resultprod = mysql_query("SELECT `inservice`,`prodid`,`prodname` FROM products ORDER BY `order` ASC") or die (mysql_error()); while ($rowprod = mysql_fetch_row($resultprod)) { $inservice = $rowprod[0]; $prodid = $rowprod[1]; $prodname = $rowprod[2]; $resultres = mysql_query("SELECT * FROM reservations WHERE `prodid` = '$prodid' AND `resdate` = '$resdate'") or die (mysql_error()); $checkres = mysql_num_rows($resultres); if ($checkres == 0) { $smallprod = $prodid ."small"; if(substr($prodid,0,2) == 'WD') { echo "<div id='test'>"; echo "<img src='images/$smallprod.jpg' width='470' height='250' border='0' title='Reserve the $prodname now!' />"; echo "<div id='test3'>"; //this is the beginning of the form(s) that I'm having problems with validating echo "<form name='reserve' action='custform.php' method='GET' onsubmit='return validateWetDry()'>"; echo "<select style='height:20px; width:175px; font-size:13px;' name='water'>"; echo "<option value='0' selected>- Choose Wet or Dry -</option>"; echo "<option value='y'>Wet Option</option>"; echo "<option value='n'>Dry Option</option>"; echo "</select><font size='-2'><br /> <br /></font>"; echo "<input type='hidden' name='resdate' value='$resdate' />"; echo "<input type='hidden' name='prodid' value='$prodid' />"; echo "<input type='submit' style='height:30px; width:175px; font-size:14px;' name='submit' value=' Reserve This Unit Now ' />"; echo "</form>"; //this is the end of the form(s) that I'm having problems with validating echo "</div>"; echo "</div>"; } else { echo "<div id='test'>"; echo "<img src='images/$smallprod.jpg' width='470' height='250' border='0' title='Reserve the $prodname now!' />"; echo "<div id='test2'>"; echo "<form name='reserve' action='custform.php' method='GET'>"; echo "<input type='hidden' name='water' value='n' />"; echo "<input type='hidden' name='resdate' value='$resdate' />"; echo "<input type='hidden' name='prodid' value='$prodid' />"; echo "<input type='submit' style='height:30px; width:175px; font-size:14px;' name='submit' value=' Reserve This Unit Now ' />"; echo "</form>"; echo "</div>"; echo "</div>"; } } else { $smallprodres = $prodid . "smallres"; echo "<img src='images/$smallprodres.jpg' width='470' height='250' border='0' title='The $prodname is not available for $resdate' />"; } ?> Javascript Code: function validateWetDry() { var water=document.forms["reserve"]["water"].value if (water==null || water=="0") { alert("Please tell us if you will need to use this unit wet or dry."); return false; } }
  7. I've been messing around with form validation and have got my code working quite well. I've replaced all the mysql() calls with PDO code and it is all working. I'm validating the form input on the client side via JQuery's validate plugin and validating it again on the server side with PHP code. I've tested the server validation with Javascript disabled in my browser and it works fine. But I have a bad feeling that I'm not doing things in the best way. I'm still new at PHP and I suspect that my basic design is just not what it should be. I hope people here can suggest a better approach. I've basically got three files associated with each form: an .shtml page that contains the form itself and invokes JQuery to validate the contents of the form on the client side a php file that re-validates the input data from the form and then inserts a row to a mysql database via PDO a "thank you" .shtml page that confirms that the data has been successfully stored in the database The PHP file includes both of the .shtml pages and the main .shtml page, the one with the form, identifies the .PHP file in the Action parameter. Here's why I think the design is not right: Error messages from server validation appear at the bottom of the same page containing the form. That's actually what I want but I'm concerned that when I look at the page source in the browser, it shows the errors are written after the </html> tag. That doesn't feel right to me. By the same token, if there are no errors, I write a couple of lines of text to the page that tell the user that there were no (server-side) validation errors and that the data was successfully written to the database. Those lines also appear at the bottom of that same page after the </html> tag. Assuming there were no server-side validation errors, the contents of the "thank you" page appear directly below everything else on the page. Again, that is after the </html> page. Am I correct in believing that my design is not ideal? I'd be willing to post my code here if it would help you get a better picture of what I'm doing. In fact, I asked a week or two back if I could post it and get people to walk through it but no one replied one way or the other to indicate if that was acceptable in this forum so I took that as a "no".
  8. I'm nearly finished writing my first php programs. (I've got experience writing code in other languages, including Java, but this is my first PHP code.) They are basically forms that the user completes to propose meeting topics of different kinds for the bookclub to which I belong. My code uses JQuery's validate plugin to check the data on the client side, then uses php to re-validate the code on the server side, in the event that the user has Javascript turned off in their browser. If the validations on both sides are successful, a row is inserted into a MySQL table. All of this works pretty much perfectly, although I haven't tested all that thoroughly yet. (I've got one issue re apostrophes that I've posted about separately.) Since these are my first programs in an unfamiliar language, I'm not at all sure that I'm doing everything the best possible way. I'm especially concerned that I may not be structuring the HTML, JQuery validations and php code the way they should be done. I would love to post my code here and get the equivalent of a code walkthru with suggestions on what I need to do to make my program the best it can be. Is that acceptable within the culture of this forum? This is strictly a spare-time/hobby effort and I have no peer group to review this code for me. These are my first uses of JQuery and PHP in any setting. I'm just looking for informal comments on what I'm doing wrong and how to make the code better. I know from other languages that you can write code that compiles and executes and does what it is supposed to do but still have really awful code. I'd like to see what needs to be done to get my structure and style up to professional standards. So, would it be okay for me to post one of my programs here for your comments? I assure you that it is NOT a lengthy program with thousands of lines of code. There are just three files: the first contains the HTML for the form and the JQuery validations and is presently 109 lines. The second is my php code which does the server side validations; it's presently 114 lines. The third is a trivial HTML file that basically thanks the user for inputting a suggesting and helps him navigate a bit; it is just 15 lines.
  9. I have a mostly working example of a real form I'm building for a website and would like to ask some questions about the parts I don't understand. This is my first form validation code in PHP. I'm very new to PHP but have coded in several other languages over the years, including form validation, so it's mostly a matter of learning how to do this in PHP rather than learning how to do it from scratch in my first language. The basic approach was taken from a reply to another question I asked in the Design portion of these forums. Here is my form, called topic_proposal.shtml: <html> <head> <link rel="stylesheet" type="text/css" href="css/main.css" media="screen"/> <link rel="stylesheet" type="text/css" href="css/print.css" media="print"/> </head> <body> <h1>Meeting Topic Proposal Form</h1> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <p>Use this form to make a suggestion for a future meeting topic. All of the fields are mandatory, except for the Comments field. Complete the form and press the Submit button. To clear the form without submitting it, press the Reset button.</p> Topic proposal submitted by: <input type="text" name="proposer" size="30" value=""/></br></br> <fieldset><legend>Proposed Topic</legend> Topic Title: <input type="text" name="topic" size="50" value=""/></br></br> Author/Director: <input type="text" name="creator" size="30" value=""/></br></br> Topic Type: <select name="topic_type"> <option value="Book">Book</option> <option value="Film">Film</option> <option value="TV">TV (Movie, Series, or Miniseries)</option> <option value="Theme">Theme</option> <option value="Other">Other</option> </select></br> </fieldset> <br/><br/> <fieldset><legend>Availability</legend> Library Availability: <input type="radio" name="library_availability" value="Yes">Yes <input type="radio" name="library_availability" value="No">No <input type="radio" name="library_availability" value="N/A">N/A</br></br> Bookstore Availability (Mass-market paperback or Trade paperback): <input type="radio" name="bookstore_availability" value="Yes">Yes <input type="radio" name="bookstore_availability" value="No">No <input type="radio" name="bookstore_availability" value="N/A">N/A</br></br> </fieldset> <br/><br/> Brief Synopsis:<br> <textarea name="synopsis" rows="10" cols="50"></textarea></br></br> Additional Comments:<br> <textarea name="comments" rows="10" cols="50"></textarea></br></br> <input type="hidden" name="_submit_check" value="1"/> <input name="submitForm" id="submitForm" type="submit" value="Submit" /> <input name="reset" id="reset" type="reset" value="Reset" /> </form> </body> </html> This is the confirmation if the insert of the new row works correctly, topic_proposal_accepted.shtml: <!DOCTYPE html> <html> <head> <title>Thank You!</title> </head> <body> <h1>Thank you!</h1> <p>Your proposed topic has been added to the database. It will be considered at the next planning session. Planning sessions are typically held during the regular June and December meetings.</p> <p>You can <a href="topic_proposal.php">make another suggestion</a> or <a href="index.shtml">return to the home page</a>.</p> </body> </html> And this is the php code that shows and validates the form, topic_proposal.php: <?php $debug = 1; $Defaults = array(); $Errors = array(); include('topic_proposal.shtml'); if ($debug) { echo 'Current php version: ' . phpversion() . '<br/>'; //Gives 5.3.19 on absolut server on 2013-01-18 echo 'Request method: ' . $_SERVER['REQUEST_METHOD'] . '<br/>'; //determine request method } if ($debug) {echo "Count: " . count($_POST) . "<br/>";} /* If any of the form elements were completed, validate them. If all elements were valid, insert a record * to the database. */ if (count($_POST) > 0) { $Defaults = $_POST; $proposer = $_POST['proposer']; $topic = $_POST['topic']; $creator = $_POST['creator']; $topic_type = $_POST['topic_type']; $library_availability = $_POST['library_availability']; $bookstore_availability = $_POST['bookstore_availability']; $synopsis = $_POST['synopsis']; $comments = $_POST['comments']; if ($debug) { echo "Proposer: $proposer<br/>"; echo "Topic: $topic<br/>"; echo "Creator: $creator<br/>"; echo "Topic type: $topic_type<br/>"; echo "Library availability: $library_availability<br/>"; echo "Bookstore availability: $bookstore_availability<br/>"; echo "Synopsis: $synopsis<br/>"; echo "Comments: $comments<br/>"; } /* Verify that all mandatory fields contain data. The radio buttons and dropdown lists will inevitably contain * so assume that it is accurate. */ if (empty($proposer) || strlen(trim($proposer))==0) { $Errors[] = 'The name of the person proposing the topic is a required field. Example: Bob T.'; } if (empty($topic) || strlen(trim($topic))==0) { $Errors[] = 'The topic is a required field. Example: The War of the Worlds'; } if (empty($creator) || strlen(trim($creator))==0) { $Errors[] = 'The creator is a required field. Example: H. G. Wells'; } if (empty($synopsis) || strlen(trim($synopsis))==0) { $Errors[] = 'The synopsis is a required field. Example: A short story about the consequences of time travel.'; } /* Verify that no text field or text area contains more data than the maximum for that field. */ if (strlen(trim($proposer))>30) { $Errors[] = 'The proposer cannot exceed 30 characters. Please shorten your input.'; //colour any input over the maximum length red so user knows how short it needs to be } if (strlen(trim($topic))>50) { $Errors[] = 'The topic cannot exceed 50 characters. Please shorten your input.'; } if (strlen(trim($creator))>30) { $Errors[] = 'The creator cannot exceed 30 characters. Please shorten your input.'; } if (strlen(trim($synopsis))>500) { $Errors[] = 'The proposer cannot exceed 500 characters. Please shorten your input.'; } if (strlen(trim($comments))>500) { $Errors[] = 'The comments cannot exceed 500 characters. Please shorten your input.'; } /* Cross checks */ //If the type is Theme, library and bookstore availability must be N/A. if ($topic_type = 'Theme') { if ($library_availability = 'Yes' || ($library_availability = 'No')) { $Errors[] = "When the topic type is Theme, library availability must be N/A. Please change it."; } if ($bookstore_availability = 'Yes' || ($bookstore_availability = 'No')) { $Errors[] = "When the topic type is Theme, bookstore availability must be N/A. Please change it."; } } //If the type is Book, library and bookstore availability must be Yes or No. if ($topic_type = 'Book') { if ($library_availability = 'N/A') { $Errors[] = "When the topic type is Book, library availability must be Yes or No. Please change it."; } if ($bookstore_availability = 'N/A') { $Errors[] = "When the topic type is Book, bookstore availability must be Yes or No. Please change it."; } } if (count($Errors)==0){ echo "<h3>Your data has all been validated successfully. Attempting to insert into database...</h3>"; Insert_Proposal($proposer, $topic, $creator, $topic_type, $library_availability, $bookstore_availability, $synopsis, $comments); } else { echo "<p>The form contains errors as noted below. Please fix them and then press the Submit button again.</p>"; foreach ($Errors as $oneError) { echo "<p>" . $oneError . "</p>"; } } } function Insert_Proposal($proposer, $topic, $creator, $topic_type, $library_availability, $bookstore_availability, $synopsis, $comments) { $debug = 1; //temporary include('#php-signin-insert.shtml'); //Sign in, connect and select database $date_proposed = date('Y-m-d'); //The date is generated here, not obtained from the form. if ($debug) { echo "Date proposed: $date_proposed<br/>"; echo "Proposer: $proposer<br/>"; echo "Topic: $topic<br/>"; echo "Creator: $creator<br/>"; echo "Topic type: $topic_type<br/>"; echo "Library availability: $library_availability<br/>"; echo "Bookstore availability: $bookstore_availability<br/>"; echo "Synopsis: $synopsis<br/>"; echo "Comments: $comments<br/>"; } $insert = "INSERT INTO TopicProposals (Date_Proposed, Proposer, Topic, Creator, Topic_Type, Library_Availability, Bookstore_Availability, Synopsis, Comments) VALUES ('$date_proposed', '$proposer', '$topic', '$creator', '$topic_type', '$library_availability', '$bookstore_availability', '$synopsis', '$comments')"; echo "Insert statement: " . $insert . '<b/>'; $result = mysql_query($insert, $con); if (!$result) { throw new Exception('Insert of Topic Proposal into table failed. Please contact the webmaster. Error number: ' . mysql_errno($con) . '. Error message: ' . mysql_error($con)); } include('topic_proposal_accepted.shtml'); mysql_close($con); } ?> I won't bother showing you #php-signin-insert.shtml since it is working fine; it simply initializes a few variables, gets the connection and then selects the appropriate database. I'm also not showing you the definition of the database table since I can't think of a good reason for you wanting to see it. All the fields in the table are Varchars, except for date_proposed, which is a Date. If you execute this code, just comment out the Insert statement and the exception handling for the insert and you should be good to go. As I said, the code mostly works and will successfully insert records into the MySQL database as long as a I comment out the cross-checks involving topic_type, library_availability and bookstore_availability. That's my first question. 1. If I complete the form by choosing a topic type of Book, all four of the cross-check errors are displayed, even if I have chosen Yes or No for the bookstore and library availability radio buttons. Why? 2. If the cross-checks detect an error, the error messages are displayed but the form itself gets blanked out, as if the Reset button had been clicked. Why? 3. If the edits show no errors and the insert is successful, the "Thank you" page appears at the end of the page, not on a new page. What would I need to do put the "Thank you" page on a fresh page? 4. How can I position the cursor with PHP? I'd like to be able to set the cursor on the first error that is discovered by the edits but I'm not sure how that's done. I don't see anything (relevant) in the PHP manual when I search on "cursor". I gather I can use Javascript to set the focus but I'd rather stay pure PHP if I can. If I must use Javascript, how do I execute Javascript statements within PHP? Or can I just code them as if they were PHP statements? 5. I was going to ask if there is a debugger for PHP in Eclipse, my IDE, but Google has helped me determine that there is. Apparently it can use either Zend or XDebug. Which of the two seems to be the best? I'm running PHP 5.3.19 if that makes a difference. I should mention that I don't have a development environment on my computer; I'm using a hosting service which has PHP installed on it and that's the level they're running. That means I can't alter their setup if it isn't to my liking but, so far, that hasn't been a problem.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.