krazigoddezz Posted June 4, 2010 Report Share Posted June 4, 2010 so im getting married in oct (yay) and working on creating an rsvp and guest book for the website. we are reserving seats for our guest because there are tons of people we still want to invite and dont want a bunch of people we dont know coming. right now i find the rsvp a priority and ill worry about the guest book later. i dont know php very well and i know a little bit about sql so im doing the best i can looking through previous posts, college textbooks, and class notes but i feel like im missing something major (i have yet to test this out because i just found out that my access to my database through my university is blocked). what i want to do is create a database has one table called guest. guest will have 4 attributes: first_name, last_name, guest_count, and guest_allowed. The primary keys are of course first_name and last_name. what i plan to end up with is: create table guest ( first_name varchar(20) not null, last_name varchar(20) not null, guest_count integer not null, guest_allowed integer not null, primary key (first_name, last_name) ); i want to add in all the guests on my guest list so when they visit the website they can update the number of people coming since 0 will be the default. so the form is very simple and on rsvp.html: <form method="post" action="guestRSVP.php"> <p class="style1">First Name: <input name="first_name" type="text" id="first_name" maxlength="15" size="30"/> </p> <p class="style1">Last Name: <input type="text" name="last_name" id="last_name" maxlength="15" size="30"/> </p> <p class="style1">Number of guests: <input name="guest_count" type="text" id="guest_count" /> </p> <p class="style1"> <input type="submit" value="Submit" /> <input type="reset" value = "Clear"> </p> </form> so i worked on guestRSVP.php and this is what i have so far: <?php if($Submit) { //Connect to and use database $conn = mysql_connect("localhost", "user", "password") or die ("Logging was not succeeded"); mysql_select_db("database"); //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)"); //If update is possible or not possible if (!$result)// Was not updated { $error= mysql_error(); $errorno=mysql_errno(); print("<br/>"); if ($errorno== 1062) { print("<TR><TH> Sorry. Your RSVP was not completed. Please make sure you are entering the name written on the invitation and selecting the number of guests less than or equal to the number of your reserved seats.</TH> </TR>"); } else//Was updated { print("<br/>"); print("<TR><TH> Your RSVP has been completed.</TH> </TR> "); } //End database connection mysql_close($conn); } else { echo("problem with submit"); } ?> i have a strong gut feeling that something is wrong with: //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)"); i think it has to do with the '$guest_count'<=guestAllowed. I don't want the guests to be able to update their record if i specified that they can have only 3 guests and they are trying to put down 5. i have also thought that i might want to make a second table and name it theRSVP which has the foreign keys of fname and lname and gAllowed and have guestCount as a regular attribute. i know this is something simple, it just that im very skilled in doing this. thanks so much in advance for any replies. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 4, 2010 Report Share Posted June 4, 2010 To save me a bit of time setting this all up on my computer, what happens when you run the code at the moment? If you are getting errors or it isn't working, what specifically is the issue at the moment? (and congrats on getting married! ) Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 6, 2010 Author Report Share Posted June 6, 2010 it doesnt work. i keep getting this: and in addition to this.. i cant access the local host.. i reinstalled appserv and configured it and still it wont work.... so in the next few days ill just have to individually install apache, mysql and php.... Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 6, 2010 Report Share Posted June 6, 2010 You may want to look at this line: else//Was updated I can't comment on the localhost issue, but I believe adding a space between the "else" and "//Was" may help. I'm guessing that PHP is interpreting that line as one long line, rather than as two separate statements. Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 7, 2010 Author Report Share Posted June 7, 2010 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. Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 21, 2010 Author Report Share Posted June 21, 2010 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. Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 21, 2010 Author Report Share Posted June 21, 2010 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.. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 21, 2010 Report Share Posted June 21, 2010 What's the complete code you are using at the moment? Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 21, 2010 Author Report Share Posted June 21, 2010 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); } Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 21, 2010 Author Report Share Posted June 21, 2010 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. Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 21, 2010 Author Report Share Posted June 21, 2010 <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> Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 22, 2010 Report Share Posted June 22, 2010 I think to get help with this, you'll need to post the entire code from "guestRSVP.php". If the "if($Submit)" line is the first line in guestRSVP.php, you'll have an issue since $submit hasn't been initialized. I'll wait on your response before commenting further. Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 22, 2010 Author Report Share Posted June 22, 2010 <!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> Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 22, 2010 Author Report Share Posted June 22, 2010 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> Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 22, 2010 Author Report Share Posted June 22, 2010 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. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 22, 2010 Report Share Posted June 22, 2010 This line "if($Submit)" says "if the $submit variable is true, execute the code contained within the { and }". It won't work because you never define what the variable $submit holds. I believe it will always result in a "false" message, and the code will never be executed. You should be able to safely drop that line (and the opening/closing "{}") like so: <?php //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); ?> Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 22, 2010 Report Share Posted June 22, 2010 I should also mention... If you are inserting this data gotten from the user directly into the database, you really should be making sure that the user hasn't purposely/accidentally entered any dangerous data. If you don't clean your input, it would be easy for someone to mess with your database or potentially even delete database tables. More info on SQL injection: http://www.tizag.com/mysqlTutorial/mysql-php-sql-injection.php At the very least, you probably should be using mysql_real_escape_string() to help clean any input. The link above explains how to go about that. Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 23, 2010 Author Report Share Posted June 23, 2010 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. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 23, 2010 Report Share Posted June 23, 2010 Sure thing. If you have any more issues, feel free to post your questions (and preferably your updated code) here. Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 23, 2010 Author Report Share Posted June 23, 2010 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? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 23, 2010 Report Share Posted June 23, 2010 To start with, I'm getting a Javascript syntax error on this line: var parsed = /^\d{1}$; (line 72) Unfortunately I know little about Javascript regular expressions, so hopefully someone else here will be able to help you out with this. Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 23, 2010 Author Report Share Posted June 23, 2010 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? Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 23, 2010 Author Report Share Posted June 23, 2010 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? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted June 23, 2010 Report Share Posted June 23, 2010 when i input data correctly it still gives me the error message. are you getting that too? Yes. Quote Link to comment Share on other sites More sharing options...
krazigoddezz Posted June 24, 2010 Author Report Share Posted June 24, 2010 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.