Jump to content

krazigoddezz

Member
  • Posts

    43
  • Joined

  • Last visited

krazigoddezz's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I see what you mean. The blue boxes... Try setting your border to 0px for the div or table. If it's not that, you need to see if you have borders on the images themselves and remove those or set them to 0px. Hope that solves your problem.
  2. ok i just finished fixing it after about 45 mins when i realized i forgot to set it to is not. thats why it wasnt working. and i fixed up the regExp <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script type="text/javascript"> function validateFormOnSubmit(theForm) { var reason = ""; reason += validateFirst_Name(theForm.first_name); reason += validateLast_Name(theForm.last_name); reason += validateGuest_Count(theForm.guest_count); if (reason != "") { alert("Some fields need correction:\n" + reason); return false; } return true; } function validateEmpty(fld) { var error = ""; if (fld.value.length == 0) { fld.style.background = 'gray'; error = "The required field has not been filled in.\n" } else { fld.style.background = 'White'; } return error; } function validateFirst_Name(fld) { var error = ""; var illegalChars = /^([a-zA-Z ]+)$/; // allow letters and spaces if (fld.value == "") { fld.style.background = 'gray'; error = "You didn't enter a first name.\n"; } else if (!(illegalChars.test(fld.value))) { fld.style.background = 'gray'; error = "The first name must only have letters or spaces.\n"; } else { fld.style.background = 'White'; } return error; } function validateLast_Name(fld) { var error = ""; var illegalChars = /^([a-zA-Z -]+)$/; // allow letters, hyphens, and spaces if (fld.value == "") { fld.style.background = 'gray'; error = "You didn't enter a last name.\n"; } else if (!(illegalChars.test(fld.value))) { fld.style.background = 'gray'; error = "The last name must only have letters, hyphens, or spaces.\n"; } else { fld.style.background = 'White'; } return error; } function validateGuest_Count(fld) { var error = ""; if (fld.value == "") { error = "You didn't enter the number of guests attending.\n"; fld.style.background = 'gray'; } else if (isNaN(parseInt(fld.value))) { error = "The guest count can only be a number.\n"; fld.style.background = 'gray'; } return error; } </script> </head> <body> <form method="post" onsubmit="return validateFormOnSubmit(this)" action="#"> <p class="style1">First Name: <input name="first_name" type="text" id="first_name" maxlength="20" size="30"/> </p> <p class="style1">Last Name: <input type="text" name="last_name" id="last_name" maxlength="20" size="30"/> </p> <p class="style1">Number of guests: <input name="guest_count" type="text" id="guest_count" size="5" maxlength="1" /> </p> <p class="style1"> <input type="submit" value="Submit" /> <input type="reset" value = "Clear"> </p> </form> </body> </html> so now i just need to figure out how to validate with php and sql. which ill start on tomorrow.
  3. figured out the problem to the syntax error. its supposed to be: var parsed = /^\d{1}/$; not var parsed = /^\d{1}$; it was just missing forward slash. was that the only error you were getting? when i input data correctly it still gives me the error message. are you getting that too?
  4. oh ok... ill work on that some more then. thanks so much! i also have some questions about validating the user's input on the guest count. is it possible to call variables in the database an use php to validate it? So i figure it would be best to explaing my thought process on this since it probably changed from when i first started working on this almost a month ago even though you are fully aware but feel the need to update others reading this thread. im restricting the amount of guest that each person who receive an invitation can bring only a certain number of people. so in the database each tuple has 4 attributes: FirstName, LastName, GuestAllowed, and GuestCount and all are set at null values. so as of right now, with the form and database things ive been working on with the Falken's help, this page is just calling the first name and last name from the guest and allowing them to update if and only if the number they insert on the form is less than or equal to the GuestAllowed attribute. Right now, everyone's guestCount is at 0. So the javascript, which is currently being worked on is just to make sure there are no null fields and the user is typing in letters an numbers where they are supposed to go. now once the client side validation works works, the last part of this wedding rsvp project is that i want to be able to give the users error messages for when their information is not found in the database. I also want to give them another message if they try to rsvp with 5 guests when only 3 are allowed and remind them of the number of guests they are allowed to have. as of right now the database will not update if they type in more than 3 (which is what i want it to do). i started to work on it earlier to take a break from the javascript to realize that i have never done server side validation. so im shooting for something like: if (!($theGuestCount<=guestAllowed)){ print ("There was an error with your RSVP. You have " + guestAllowed + " reserved seats. Please check text field and try again."); } if (!($first_name=firstName) and !($last_name=lastName)){ print ("There was an error with your RSVP. You have entered an invalid first and last name combination. Please check the text field an try again.") } so.. is something like this possible? if it is.. how would i go about executing this? if not, would i need to create separate variables and set the values equal to the values in the database?
  5. the javascript validation isn't working. i tried it in both firefox and ie and i get nothing. sigh... so this is what i have: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script type="text/javascript"> function validateFormOnSubmit(theForm) { var reason = ""; reason += validateFirst_Name(theForm.first_name); reason += validateLast_Name(theForm.last_name); reason += validateGuest_Count(theForm.guest_count); if (reason != "") { alert("Some fields need correction:\n" + reason); return false; } return true; } function validateEmpty(fld) { var error = ""; if (fld.value.length == 0) { fld.style.background = 'gray'; error = "The required field has not been filled in.\n" } else { fld.style.background = 'White'; } return error; } function validateFirst_Name(fld) { var error = ""; var illegalChars = /[ a-z]$/i; // allow letters and spaces if (fld.value == "") { fld.style.background = 'gray'; error = "You didn't enter a first name.\n"; } else if (illegalChars.test(fld.value)) { fld.style.background = 'gray'; error = "The first name must only have letters or spaces.\n"; } else { fld.style.background = 'White'; } return error; } function validateLast_Name(fld) { var error = ""; var illegalChars = /[- a-z]$/i; // allow letters, hyphens, and spaces if (fld.value == "") { fld.style.background = 'gray'; error = "You didn't enter a last name.\n"; } else if (illegalChars.test(fld.value)) { fld.style.background = 'gray'; error = "The last name must only have letters, hyphens, or spaces.\n"; } else { fld.style.background = 'White'; } return error; } function validateGuest_Count(fld) { var error = ""; var parsed = /^\d{1}$; if (fld.value == "") { error = "You didn't enter the number of guests attending.\n"; fld.style.background = 'gray'; } else if (isNaN(parseInt(parsed))) { error = "The guest count can only be a number.\n"; fld.style.background = 'gray'; } else { fld.style.background = 'White'; } return error; } </script> </head> <body> <form method="post" onsubmit="return validateFormOnSubmit(this)" action="#"> <p class="style1">First Name: <input name="first_name" type="text" id="first_name" maxlength="20" size="30"/> </p> <p class="style1">Last Name: <input type="text" name="last_name" id="last_name" maxlength="20" size="30"/> </p> <p class="style1">Number of guests: <input name="guest_count" type="text" id="guest_count" size="5" maxlength="1" /> </p> <p class="style1"> <input type="submit" value="Submit" /> <input type="reset" value = "Clear"> </p> </form> </body> </html> ive used this code in the past and it doesnt work for some strange reason. any ideas?
  6. wow... i never heard of injection. i looked up on how to use it at the w3schools site because i didnt completely understand tizag. but after seeing it utilized two different ways, it makes sense. thank you. now i get what you are saying about the code not executing. so data now saves to the database (yay ). thank you so much! but now i have to create an if statement for people trying to enter in more guests than they are allowed to let them know it doesnt work and then add in some javascript to validate the textbox input to make sure there are no null fields and numbers and letters go where they are supposed to. hopefully i can remember how to since i haven't used it in years and learned the outdated codes from school. once again, thanks so much falken. if i could, i would ship you some yummy cookies or a cake (i work as a baker/cake decorator) as my thanks.
  7. so since the first line in guestRSVP.php is if($Submit), it won't work? why exactly is that? you mentioned that it will not work because $Submit has yet to be executed. isnt it executed when the user click submit on RSVP.html through the form's submit button? like i said... im a php noob and learning as i go along. Well, I just thought of something... give me a few hours... i need to proofread, edit, and provide feedback on a paper for my mommy (shes going back to school after 13+ years) and ill let you know if i get what im thinking to work or not.
  8. this is the page with the form: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>RSVP</title> <style type="text/css"> <!-- .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #161616; } body { background-color: #161616; } a:link { color: #D70000; text-decoration: none; } a:visited { text-decoration: none; color: #D70000; } a:hover { text-decoration: underline; color: #666666; } a:active { text-decoration: none; color: #D70000; } --> </style></head> <body> <div align="center"> <table width="900" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="366"><img src="images/layout_01.png" alt="header" width="980" height="366" /></td> </tr> <tr> <td valign="top" background="images/layout_03.png"><table width="975" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="346" valign="top"><blockquote> <blockquote> <p class="style1">.:| <a href="index.htm">Home</a> </p> <p class="style1">.:| <a href="AboutUs.html">About Us</a></p> <p class="style1">.:| <a href="BridalParty.html">Bridal Party</a> </p> <p class="style1">.:| <a href="WeddingReception Details.html">Wedding/Reception Details</a></p> <p class="style1">.:| <a href="OutOfTowners.html">Out of Towners</a> </p> <p class="style1">.:| <a href="GiftRegistry.html">Gift Registry</a></p> <p class="style1">.:| <a href="ContactUs.html">Contact Us</a> </p> </blockquote> </blockquote></td> <td width="629" valign="top"><p> </p> <form method="post" action="guestRSVP.php"> <p class="style1">First Name: <input name="first_name" type="text" id="first_name" maxlength="20" size="30"/> </p> <p class="style1">Last Name: <input type="text" name="last_name" id="last_name" maxlength="20" size="30"/> </p> <p class="style1">Number of guests: <input name="guest_count" type="text" id="guest_count" size="5" maxlength="2" /> </p> <p class="style1"> <input type="submit" value="Submit" /> <input type="reset" value = "Clear"> </p> </form> <p class="style1"> </p></td> </tr> </table> </td> </tr> <tr> <td><img src="images/layout_05.png" width="980" height="57" alt="footer" /></td> </tr> </table> </div> </body> </html>
  9. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Guest RSVP</title> <style type="text/css"> <!-- .style1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #161616; } body { background-color: #161616; } a:link { color: #D70000; text-decoration: none; } a:visited { text-decoration: none; color: #D70000; } a:hover { text-decoration: underline; color: #666666; } a:active { text-decoration: none; color: #D70000; } --> </style></head> <body> <div align="center"> <table width="900" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="366"><img src="images/layout_01.png" alt="header" width="980" height="366" /></td> </tr> <tr> <td valign="top" background="images/layout_03.png"><table width="975" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="346" valign="top"><blockquote> <blockquote> <p class="style1">.:| <a href="index.htm">Home</a> </p> <p class="style1">.:| <a href="AboutUs.html">About Us</a></p> <p class="style1">.:| <a href="BridalParty.html">Bridal Party</a> </p> <p class="style1">.:| <a href="WeddingReception Details.html">Wedding/Reception Details</a></p> <p class="style1">.:| <a href="OutOfTowners.html">Out of Towners</a> </p> <p class="style1">.:| <a href="GiftRegistry.html">Gift Registry</a></p> <p class="style1">.:| <a href="ContactUs.html">Contact Us</a> </p> </blockquote> </blockquote></td> <td width="629" valign="top"> <p> <?php if($Submit) { //Connect to and use database $conn = mysql_connect("server", "user", "password") or die ("Logging was not succeeded"); mysql_select_db("database"); //Make variables $first_name = $_POST[first_name]; $last_name = $_POST[last_name]; $guest_count = $_POST[guest_count]; //Make guest_count string and integer $theGuestCount= (int)$guest_count; //Update guest first name, last name, and guest count to guest table $result= mysql_query("UPDATE guest SET guestCount='$theGuestCount' WHERE $first_name=firstName and $last_name=lastName and $theGuestCount<=guestAllowed"); //If update is possible or not possible if (!$result)// Was not updated { $error= mysql_error(); $errorno=mysql_errno(); print("There was an error with your RSVP. Please try again or visit the contact us page."); } else //Was updated { print("Your RSVP has been completed."); } //End database connection mysql_close($conn); } ?> </p> </td> </tr> </table> </td> </tr> <tr> <td><img src="images/layout_05.png" width="980" height="57" alt="footer" /></td> </tr> </table> </div> </body> </html>
  10. <form method="post" action="guestRSVP.php"> <p class="style1">First Name: <input name="first_name" type="text" id="first_name" maxlength="20" size="30"/> </p> <p class="style1">Last Name: <input type="text" name="last_name" id="last_name" maxlength="20" size="30"/> </p> <p class="style1">Number of guests: <input name="guest_count" type="text" id="guest_count" size="5" maxlength="2" /> </p> <p class="style1"> <input type="submit" value="Submit" /> <input type="reset" value = "Clear"> </p> </form>
  11. now with this code, it loads the php page but it doesn't print anything to the page when the info is submitted. so it doesnt tell me whether or not the code was submitted fine or if there was an error. so the only way it can be checked if i check the database, which is still leaving the guest count at 0.
  12. if($Submit) { //Connect to and use database $conn = mysql_connect("server", "user", "password") or die ("Logging was not successful"); mysql_select_db("database"); //Make variables $first_name = $_POST[first_name]; $last_name = $_POST[last_name]; $guest_count = $_POST[guest_count]; //Make guest_count string and integer $theGuestCount= (int)$guest_count; //Update guest first name, last name, and guest count to guest table $result= mysql_query("UPDATE guest SET guestCount='$theGuestCount' WHERE $first_name=firstName and $last_name=lastName and $theGuestCount<=guestAllowed"); //If update is possible or not possible if (!$result)// Was not updated { $error= mysql_error(); $errorno=mysql_errno(); print("There was an error with your RSVP. Please try again or visit the contact us page."); } else //Was updated { print("Your RSVP has been completed."); } //End database connection mysql_close($conn); }
  13. so i created theGuestCount variable just as above, i still receive the same error but now its on the line with the </html> tag. sigh..
  14. ok.. so i found a solution to my problem... free webhost with free mysql database and can use myphpadmin. so i tested out the code and get this error after the first name, last name, and number of guests are submitted: Parse error: syntax error, unexpected $end in /home/krazigoddezz/public_html/guestRSVP.php on line 106. line 106 on the guestRSVP.php is the next line after the </html> tag. so i went back to make sure i did not miss any curly brackets and they are all there. so the only other thing i can think of is that when the user enters the number of attending guests (guest_count), that the number entered needs to be parsed from a string to an integer. so if this is the case, how exactly would i do that? //Update guest first name, last name, and guest count to guest table $result= mysql_query("update guest set (guestCount='$guest_count') where('$first_name'=first_name and '$last_name'=last_name and '$guest_count'<=guestAllowed)"); would i need to typecast and create another variable in php doing something like: $theGuestCount = (int)$guest_count; or is it possible to do so in the sql query? ill test out the typecast and respond back if it doesnt work. thanks once again.
  15. Thanks Faulken but it was a no go. I'm going to try get the localhost problem taken care of. If not I guess I'll have to take another different approach. I originally tried using Visual Studio and for some strange reason, I could not create a database. I'm beginning to think there is actually something wrong with my computer. If individually installing mysql, php, and apache does not fix my little problem, do you have any suggestions on how I should go about doing this aside from using an RSVP page from a wedding website. I'm trying to avoid that since many of them have design restrictions and are pretty much missing the personal feel I would like. If not, its okay. I see the RSVP as an add on to the website, in addition to getting me back into the web design/development groove. Once again thanks.
×
×
  • Create New...