Jump to content
Larry Ullman's Book Forums

Marie

Members
  • Posts

    148
  • Joined

  • Last visited

Everything posted by Marie

  1. Hello, Thank you. I thought that I was following another script that would make sense in this situation. I guess it is always good to get back to basics and not complicate anything. So, now the script is working and I have another scipt on the same page that is working separately. Now I have to get them working together. Hopefully, I can do that myself. I will get back to the forum. Marie
  2. Hello, I revisited my code and am it will now echo the value that I want from the database. However, when I enter that same value in the following line, I am still not getting any emails at that email address. I have tried the following: - mail(' . $row[1] . ', 'Message from SplendedTopics.com', $body, "From: {$_POST['email']}"); and also mail('$row[1]', 'Message from SplendedTopics.com', $body, "From: {$_POST['email']}"); and variations of the database query. Thanks, Marie
  3. Hello, Okay I have attempted to echoe the value and nothing came up so it is not working the way I would like it to work. Right now my code is messed up so I will have to take another look at it. Marie
  4. Hello, Yes, I have pulled up different "pages" that have been posted by my registered test members and sent emails to these people and none arrive. In all cases I am using various emails that are mine so when my test members have registered or forgotten passwords, etc. the email addresses have worked. The script is running on a server provided by a hosting service so it is live. When I used the original script from the book and used a valid email address, I was receiving emails, but of course, I want the script to accept whatever email address has been brought up by the database. From the book, // Send the email: mail('youremail@example.com', 'Message from SplendedTopics.com', $body, "From: {$_POST['email']}"); Thanks, Marie
  5. Yes, I checked the Spam. In this particular instance the email should be going to a GMAIL address. I can do other email addresses as well. Marie
  6. Hello, I am trying to set up a page where a member who is logged in can access other member's pages, then send an email to the member who has posted a certain page so that the member who is logged in can make comments. At this stage the logged in member doesn't necessarily know the email address of the member who had posted the page that the logged in member has pulled up. I have tried several combinations and I am not getting an error message. The email is not being received at the test email inbox. Any help would be appreciated. Thanks. Following is my current code: $q = "SELECT topics.users_id, users.email FROM topics INNER JOIN users ON topics.users_id = users.id WHERE topics.id=$id" ; $r = mysqli_query ($connect, $q); if (mysqli_num_rows($r) > 0) { while ($row = mysqli_fetch_array($r, MYSQLI_NUM)) { } } echo '<h3>Contact Me</h3>'; // Check for form submission: if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Minimal form validation: if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comments']) ) { // Create the body: $body = "Name: {$_POST['name']}\n\nComments: {$_POST['comments']}"; // Make it no longer than 100 characters long: $body = wordwrap($body, 100); // Send the email: mail('$row[1]', 'Message from SplendedTopics.com', $body, "From: {$_POST['email']}"); // Print a message: echo '<p><em>Thank you for contacting a member of Spendid Topics.</em></p>'; // Clear $_POST (so that the form's not sticky): $_POST = array(); } else { echo '<p style="font-weight: bold; color: #C00">Please fill out the form completely.</p>'; } } // End of main isset() IF. ?> <p>Please fill out this form to contact the poster of this notice.</p> <form action="EmailContactPoster.php" method="post"> <p>Your Name: <input type="text" name="name" size="30" maxlength="60" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></p> <p>Your Email Address: <input type="text" name="email" size="30" maxlength="80" value="<?php if (isset($_POST['email]'])) echo $_POST['email']; ?>" /></p> <p>Comments: <textarea name="comments" rows="5" cols="30"><?php if (isset($_POST['comments'])) echo $_POST['comments']; ?></textarea></p> <input type="hidden" name="id" value="' . $id . '" /> <p><input type="submit" name="submit" value="Contact Poster!" /></p> </form>
  7. Yes, it makes sense that the information would not be in the database. I thought about this later and I don't know how the form was "working" before. The form seemed to retain the information thus allowing the page to state something along the lines that the following information has been deleted. However, it makes sense to make a user and / or their information inactive in case they deleted in error or want to reactive their information at a later date or whatever. Thanks for posting your ideas. Marie
  8. Yes, you are right. Sometimes I don't know how much or how little to put in these posts. Following is the main portion of the code. I took out the bit of code that was showing up after the user deletes their page - the piece that was not needed. So right now it is working almost the way I would like, however, I would still like the user's page information to show up in the form after the user has deleted it from the database, just so that they know what they just deleted. Right now the form fields are blank after they delete it from the database. When I had the two forms separated, it was working that way, however, that was when I was getting the undefined index error. Thanks, Marie ========================================== if ($_POST['sure'] == 'Yes') { // Delete the record. // Make the query: $q = "DELETE FROM pages WHERE id=$id LIMIT 1"; $r = @mysqli_query ($connect, $q); if (mysqli_affected_rows($connect) == 1) { // If it ran OK. // Print a message: echo '<p><h3>The page has been deleted.</h3></p>'; } else { // If the query did not run OK. echo '<p class="error">The page could not be deleted due to a system error.</p>'; // Public message. echo '<p>' . mysqli_error($connect) . '<br />Query: ' . $q . '</p>'; // Debugging message. } } else { // No confirmation of deletion. echo '<p><h3>The page below has NOT been deleted.</h3></p>'; } // Make the query: $q = "UPDATE pages SET optimal='$o', alternate='$a', amount='$m', currency='$c', timeframe='$t', location='$l', description='$d' WHERE id=$id LIMIT 1"; $r = @mysqli_query ($connect, $q); if (mysqli_affected_rows($connect) == 1) { // If it ran OK. // Print a message: echo '<p><h3a>Your information has been edited.</h3a></p>'; } // End of if (empty($errors)) IF. } // Retrieve the user's information: $q = "SELECT id, optimal, alternate, amount, currency, timeframe, location, description FROM pages WHERE id=$id"; $r = @mysqli_query ($connect, $q); if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form. // Get the user's information: $row = mysqli_fetch_array ($r, MYSQLI_NUM); } else { // Show the form. }
  9. Okay, I have combined two forms into one and rearranged a few things. For the most part it works, however, I get error messages which arn't really needed. Following is my code: <?php // Check for a form submission: if ($_SERVER['REQUEST_METHOD'] == 'POST') // Check for an optimal name: //if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $_POST['optimal'])) { if (!empty($_POST['optimal'])) { $o = mysqli_real_escape_string ($connect, $_POST['optimal']); } else { $EditpagesTBR_errors['optimal'] = 'Please enter an optimal name.'; } // Check for an alternate code: //if (preg_match ('/^[A-Z0-9-0 \'.-]{2,10}$/i', $_POST['alternate'])) { if (!empty($_POST['alternate'])) { $a = mysqli_real_escape_string ($connect, $_POST['alternate']); } else { $EditpagesTBR_errors['alternate'] = 'Please enter an alternate code.'; } // Check for a amount: //if (preg_match ('/^[A-Z0-9-0 $]{2,30}$/i', $_POST['amount'])) { if (!empty($_POST['amount'])) { $m = mysqli_real_escape_string ($connect, $_POST['amount']); } else { $EditpagesTBR_errors['amount'] = 'Please enter the amount.'; } // Check for a currency: //if (preg_match ('/^[A-Z0-9-0 $]{2,10}$/i', $_POST['currency'])) { if (!empty($_POST['currency'])) { $c = mysqli_real_escape_string ($connect, $_POST['currency']); } else { $EditpagesTBR_errors['currency'] = 'Please enter the currency'; } // Check for a tiimeframe: //if (preg_match ('/^[A-Z0-9-0 \'.-]{2,40}$/i', $_POST['timeframe'])) { if (!empty($_POST['timeframe'])) { $t = mysqli_real_escape_string ($connect, $_POST['timeframe']); } else { $EditpagesTBR_errors['timeframe'] = 'Please enter when this happened'; } // Check for a location: //if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $_POST['location'])) { if (!empty($_POST['location'])) { $l = mysqli_real_escape_string ($connect, $_POST['location']); } else { $EditpagesTBR_errors['location'] = 'Please enter the location.'; } // Check for a description: //if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $_POST['description'])) { if (!empty($_POST['description'])) { $d = mysqli_real_escape_string ($connect, $_POST['description']); } else { $EditpagesTBR_errors['description'] = 'Please enter a description.'; } if (empty($EditpagesTBR_errors)) { // If everything's OK... if ($_POST['sure'] == 'Yes') { // Delete the record. // Make the query: $q = "DELETE FROM pages WHERE id=$id LIMIT 1"; $r = @mysqli_query ($connect, $q); if (mysqli_affected_rows($connect) == 1) { // If it ran OK. // Print a message: echo '<p><h3>The page has been deleted.</h3></p>'; } else { // If the query did not run OK. echo '<p class="error">The Notice could not be deleted due to a system error.</p>'; // Public message. echo '<p>' . mysqli_error($connect) . '<br />Query: ' . $q . '</p>'; // Debugging message. } } else { // No confirmation of deletion. echo '<p><h3>The Above page has NOT been deleted.</h3></p>'; } // Make the query: $q = "UPDATE pages SET optimal='$o', alternate='$a', amount='$m', currency='$c', timeframe='$t', location='$l', description='$d' WHERE id=$id LIMIT 1"; $r = @mysqli_query ($connect, $q); if (mysqli_affected_rows($connect) == 1) { // If it ran OK. // Print a message: echo '<p><h3a>Your information has been edited.</h3a></p>'; } else { // If it did not run OK. echo '<p class="error">The user could not be edited due to a system error. We apologize for any inconvenience.</p>'; // Public message. echo '<p>' . mysqli_error($connect) . '<br />Query: ' . $q . '</p>'; // Debugging message. } } // End of if (empty($errors)) IF. // Retrieve the user's information: $q = "SELECT id, optimal, alternate, amount, currency, timeframe, location, description FROM pages WHERE id=$id"; $r = @mysqli_query ($connect, $q); if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form. // Get the user's information: $row = mysqli_fetch_array ($r, MYSQLI_NUM); } else { // Show the form. } // Create the form: echo '<form action="page.php" method="post"> <p>optimal:</p> <input type="text" name="optimal" size="40" maxlength="15" value="' . $row[1] . '" /></p> <p>Alternate:</p> <input type="text" name="alternate" size="40" maxlength="40" value="' . $row[2] . '" /></p> <p>Amount:</p> <input type="text" name="amount" size="40" maxlength="30" value="' . $row[3] . '" /></p> <p>Currency:</p> <input type="text" name="currency" size="40" maxlength="60" value="' . $row[4] . '" /> </p> <pTimeframe:</p> <input type="text" name="timeframe" size="40" maxlength="40" value="' . $row[5] . '" /> </p> <p>Location:</p> <input type="text" name="location" size="40" maxlength="15" value="' . $row[6] . '" /></p> <p>Description:</p> <input type="textarea" name="description" size="60" maxlength="100" value="' . $row[7] . '" /></p> <h3> Are you sure you want to delete your page?</h3> <input type="radio" name="sure" value="Yes" /> Yes <input type="radio" name="sure" value="No" checked="checked" /> No <input type="submit" name="submit" value="Submit" /> <input type="hidden" name="id" value="' . $id . '" /> </form>'; ?>
  10. Makes sense. I am working on it and it is working better, however, not quite what I am looking for yet. Thanks, Marie
  11. Thank you for your suggestions. I will work on this and get back to the forum. Having this set up as one form makes a lot of sense. Marie
  12. Hello: If someone hits submit for the editing portion WITHOUT changing anything, then I get a "user could not be updated due to a system error and then an "undefined Index: sure" in place of the form to delete the page. If someone updates the update form then it gets updated but I still get the "undefinied index: sure" error in place of the form to delete the page. The code APPEARS to work only when the person actually deletes or not deletes their post so when they the second submit button page appears to be functioning properly. Following is my code: <?php // Check for a form submission: if ($_SERVER['REQUEST_METHOD'] == 'POST') // Check for an optimal name: //if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $_POST['optimal'])) { if (!empty($_POST['optimal'])) { $o = mysqli_real_escape_string ($connect, $_POST['optimal']); } else { $errors['optimal'] = 'Please enter an optimal name.'; } // Check for an alternate code: //if (preg_match ('/^[A-Z0-9-0 \'.-]{2,10}$/i', $_POST['alternate'])) { if (!empty($_POST['alternate'])) { $a = mysqli_real_escape_string ($connect, $_POST['alternate']); } else { $errors['alternate'] = 'Please enter an alternate code.'; } // Check for a amount: //if (preg_match ('/^[A-Z0-9-0 $]{2,30}$/i', $_POST['amount'])) { if (!empty($_POST['amount'])) { $m = mysqli_real_escape_string ($connect, $_POST['amount']); } else { $errors['amount'] = 'Please enter the amount.'; } // Check for a currency: //if (preg_match ('/^[A-Z0-9-0 $]{2,10}$/i', $_POST['currency'])) { if (!empty($_POST['currency'])) { $c = mysqli_real_escape_string ($connect, $_POST['currency']); } else { $errors['currency'] = 'Please enter the currency'; } // Check for a tiimeframe: //if (preg_match ('/^[A-Z0-9-0 \'.-]{2,40}$/i', $_POST['timeframe'])) { if (!empty($_POST['timeframe'])) { $t = mysqli_real_escape_string ($connect, $_POST['timeframe']); } else { $errors['timeframe'] = 'Please enter when this happened'; } // Check for a location: //if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $_POST['location'])) { if (!empty($_POST['location'])) { $l = mysqli_real_escape_string ($connect, $_POST['location']); } else { $errors['location'] = 'Please enter the location.'; } // Check for a description: //if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $_POST['description'])) { if (!empty($_POST['description'])) { $d = mysqli_real_escape_string ($connect, $_POST['description']); } else { $errors['description'] = 'Please enter a description.'; } if (empty($errors)) { // If everything's OK... // Make the query: $q = "UPDATE pages SET optimal='$o', alternate='$a', amount='$m', currency='$c', timeframe='$t', location='$l', description='$d' WHERE id=$id LIMIT 1"; $r = @mysqli_query ($connect, $q); if (mysqli_affected_rows($connect) == 1) { // If it ran OK. // Print a message: echo '<p><h3a>Your information has been edited.</h3a></p>'; } else { // If it did not run OK. echo '<p class="error">The user could not be edited due to a system error. We apologize for any inconvenience.</p>'; // Public message. echo '<p>' . mysqli_error($connect) . '<br />Query: ' . $q . '</p>'; // // Retrieve the user's information: $q = "SELECT id, optimal, alternate, amount, currency, timeframe, location, description FROM pages WHERE id=$id"; $r = @mysqli_query ($connect, $q); if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form. // Get the user's information: $row = mysqli_fetch_array ($r, MYSQLI_NUM); // Create the form: echo '<form action="page.php" method="post"> <p>optimal:</p> <input type="text" name="optimal" size="40" maxlength="15" value="' . $row[1] . '" /></p> <p>Alternate:</p> <input type="text" name="alternate" size="40" maxlength="40" value="' . $row[2] . '" /></p> <p>Amount:</p> <input type="text" name="amount" size="40" maxlength="30" value="' . $row[3] . '" /></p> <p>Currency:</p> <input type="text" name="currency" size="40" maxlength="60" value="' . $row[4] . '" /> </p> <pTimeframe:</p> <input type="text" name="timeframe" size="40" maxlength="40" value="' . $row[5] . '" /> </p> <p>Location:</p> <input type="text" name="location" size="40" maxlength="15" value="' . $row[6] . '" /></p> <p>Description:</p> <input type="textarea" name="description" size="60" maxlength="100" value="' . $row[7] . '" /></p> <p><input type="submit" name="submit" value="Submit" /></p> <input type="hidden" name="id" value="' . $id . '" /> </form>'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_POST['sure'] == 'Yes') { // Delete the record. // Make the query: $q = "DELETE FROM pages WHERE id=$id LIMIT 1"; $r = @mysqli_query ($connect, $q); if (mysqli_affected_rows($connect) == 1) { // If it ran OK. // Print a message: echo '<p><h3>The page has been deleted.</h3></p>'; } else { // If the query did not run OK. echo '<p class="error">The Page could not be deleted due to a system error.</p>'; // Public message. echo '<p>' . mysqli_error($connect) . '<br />Query: ' . $q . '</p>'; // Debugging message. } } else { // No confirmation of deletion. echo '<p><h3>The Above Page has NOT been deleted.</h3></p>'; } } else { // Show the form. // Retrieve the user's information: $q = "SELECT id, optimal, alternate, amount, currency, timeframe, location, description FROM pages WHERE id=$id"; $r = @mysqli_query ($connect, $q); if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form. // Get the user's information: $row = mysqli_fetch_array ($r, MYSQLI_NUM); // Display the record being deleted: echo "<h3> Are you sure you want to delete your Page?</h3>"; // Create the form: echo '<form action="page.php" method="post"> <input type="radio" name="sure" value="Yes" /> Yes <input type="radio" name="sure" value="No" checked="checked" /> No <input type="submit" name="submit" value="Submit" /> <input type="hidden" name="id" value="' . $id . '" /> </form>'; } else { // Not a valid user ID. echo '<p class="error">This page has been accessed in error.'; } } } ?>
  13. Hello, Is it possible to have two form submissions on one page? I would lke my user to be able to delete or edit their record on the same page. So far my code almost works however, I am now wondering if I am trying to do something that can't be done. The user accesses their record from a list on another page. Then the information is passed through an id in a URL to a page where the record is displayed in full. Thanks, Marie
  14. What exactly do you mean by a self numbering ID - an auto incremental key?
  15. Thank you for your quick reply. if (mysqli_num_rows($r) == 0) { I changed the "0" to a "1" in the above line and then the user was allowed to just change their username. However IF then the user decides to then change their email address it returns the message that the email has already been registered even though there is definitely no email at all like the one they are entering in the data base that I have set up. So I will keep working on this. Marie
  16. Hello, The text in this chapter seems to indicate that a user can just change their name or whatever and they don't have to touch the email address. I would like my form set up so that the user can do one or the other. However, when testing my page the user is not allowed to only submit a change of username. I get - This email has already been registered. I have fooled around with the code and now back to my original which is follows - <?php // Check if the form has been submitted: if ($_SERVER['REQUEST_METHOD'] == 'POST') { $errors = array(); // Check for a username: if (empty($_POST['username'])) { $errors[] = 'You forgot to enter your username.'; } else { $un = mysqli_real_escape_string($connect, trim($_POST['username'])); } // Check for an email address: if (empty($_POST['email'])) { $errors[] = 'You forgot to enter your email address.'; } else { $e = mysqli_real_escape_string($connect, trim($_POST['email'])); } if (empty($errors)) { // If everything's OK. // Test for unique email address: $q = "SELECT id FROM users WHERE email='$e' AND id={$_SESSION['user_id']}"; $r = @mysqli_query($connect, $q); if (mysqli_num_rows($r) == 0) { // Make the query: $q = "UPDATE users SET username='$un', email='$e' WHERE id={$_SESSION['user_id']} LIMIT 1"; $r = @mysqli_query ($connect, $q); if (mysqli_affected_rows($connect) == 1) { // If it ran OK. // Print a message: echo '<p>The user has been edited.</p>'; } else { // If it did not run OK. echo '<p class="error">The user could not be edited due to a system error. We apologize for any inconvenience.</p>'; // Public message. echo '<p>' . mysqli_error($connect) . '<br />Query: ' . $q . '</p>'; // Debugging message. } } else { // Already registered. echo '<p class="error">The email address has already been registered.</p>'; } } else { // Report the errors. echo '<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>'; } // End of if (empty($errors)) IF. } // End of submit conditional. // Always show the form... //id={$_SESSION['user_id']} // Retrieve the user's information: $q = "SELECT username, email FROM users WHERE id={$_SESSION['user_id']}"; $r = @mysqli_query ($connect, $q); if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form. // Get the user's information: $row = mysqli_fetch_array ($r, MYSQLI_NUM); // Create the form: echo '<form action="MemberProfileTBR.php" method="post"> <p>Userame: <br /> <input type="text" name="username" size="40" maxlength="40" value="' . $row[0] . '" /></p> <p>Email Address: <br /> <input type="text" name="email" size="40" maxlength="60" value="' . $row[1] . '" /> </p> <p><input type="submit" name="submit" value="Edit" /></p> <input type="hidden" name="id" value="' . $_SESSION['user_id'] . '" /> </form>'; } else { // Not a valid user ID. echo '<p class="error">This page has been accessed in error.</p>'; } mysqli_close($connect); ?> Thanks, Marie
  17. Right at the moment I am not into learning JavaScript or jQuery so I may just revert back to the original PHP. I hope that if I limit the database to 200 characters or whatever then it will not accept any more than that. Thanks for your help. Marie
  18. After trying several things in the php page I went back to the forms function page and inserted the following code: // Start creating the textarea: echo "<textarea name="limitedtextarea" onKeyDown="limitText(this.form.limitedtextarea,this.form.countdown,100);" onKeyUp="limitText(this.form.limitedtextarea,this.form.countdown,100) <font size="1">(Maximum characters: 300)<br> You have <input readonly type="text" name="countdown" size="5" value="300"> characters left.</font> I get the following error - Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'. So I know that it cannot be correct and I have experimented by doing various things and nothing has worked so far. Just need to know if I am putting this code in the right place at all. I have also tried putting the words <script> and <javascript> and variations in this code but this has not worked either. When I put the Javascript on the php page I was getting two text areas - the one that was originally there that was sticky and the newer one that showed the counter and characters that were remaining. Obviously I don't want both and am trying to combine them. So I know that the javascript itself was working. I was getting a text area with a counter but it was not sticky or posting any errors. Marie
  19. Thanks for your replies, I noticed on the W3 schools website it says that IE and Opera doesn't support limiting the characters in a text area. This can be done in Dreamweaver with Javascript with a counter but I prefer to use PHP and be consistent with the scripting as it is presented in Larry's books. I am a Mac person and generally use Firefox as my browser. However, I tried the following and it works somewhat. The characters are limited but the text area box spreads to about three times the width as well. I am still working on it. echo '<textarea name="' . $name . '" id="' . $name . '" cols="150" rows="5" maxlength="25"'; Marie
  20. Okay I have been fooling around with this in the forms function script and on the php page itself and figure that I should be able to do this in the forms function. The following however, did not work so I am wondering about the proper coding. echo '<textarea name="' . $name . '" id="' . $name . '" rows="5" cols="150" minChars="2" maxChars="300"'; Can I write Javascipt within PHP? Thanks, Marie
  21. 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
  22. Hello, I revisited this and the following code seems to work for me when I place this in the appropriate spot on any page. <?php $q = "SELECT id, username FROM users WHERE id={$_SESSION['user_id']}"; $r = mysqli_query($connect, $q); if (mysqli_num_rows($r) > 0) { while ($row = mysqli_fetch_array($r, MYSQLI_NUM)) { echo "<h3>Welcome $row[1]! You can change your password here.</h3>"; } } echo '</p>'; ?>
  23. Just curious about another aspect of this whole thing. IF I treat this registration form in the same manner as the add_pdf file, and use this code - if (!empty($_POST['title'])) { instead of - if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $_POST['organization'])) { Everything seems to get entered into the data base just fine, including apostophes and other foreign characters. So I am now wondering why anyone would use the preg_match code. Marie
  24. A slight variation to this problem. When I try to add stickiness to the text area I get an undefined variable error. Following is my code. <textarea name="comments" rows="5" cols="45" ><?php echo $comments; $PostANoticeTBR_errors; ?> </textarea> I have played around with the code and I seem to get an undefined variable no matter what I do. Marie
  25. Okay this is what I have done that seems to work so far. The data is being entered and there are no slashes in the database. I followed the advice given above for the form validation and added stripslashes before the $_POST. This allowed my form to accept the apostrophe in the name. THEN I added stripslashes to the SQL code that enteres the values into the database. // Check for a first name: if (preg_match ('/^[A-Z \'.-]{2,20}$/i', stripslashes($_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', stripslashes($_POST['last_name']))) { $ln = mysqli_real_escape_string ($connect, $_POST['last_name']); $q = "INSERT INTO users (username, email, pass, first_name, last_name, date_expires) VALUES ('$u', '$e', '" . get_password_hash($p) . "', '" . stripslashes($fn) . "', '" . stripslashes($ln) . "', SUBDATE(NOW(), INTERVAL 1 DAY) )";
×
×
  • Create New...