djcochran Posted April 10, 2009 Share Posted April 10, 2009 I already have a form (written in HTML and uses JAVASCRIPT to check some errors) for registering, and I want to send that information to an already created MYSQL table. I'm having...well...a lot of trouble. I don't even know where to begin. You can skip through most of this stuff, it's just the form and everything. The php code just reads in from template.data and sets up the page layout. I guess I have to create another php script outside of this one that reads in the data and sends it the server. Any hints/tips on how to do this? And any places where I can read up on this stuff is cool. I've found a few sites myself...but the more the better. <?php $file = fopen("template.data", "r"); while(!feof($file)) { $line = fgets($file); if(preg_match("/@@CONTENT_HERE@@/", $line, $dummyarray)){ print<<<END <script type="text/javascript"> var emailRe=/^.+@.+\..{2,3}$/; var zipCodeRe=/^[0-9][0-9][0-9][0-9][0-9]$/; var telephoneRe=/^[\(]?(\d{3})[\)]?[-\.]?(\d{3})[-\.]?(\d{4})$/; function validate_form(){ valid = true; if(document.join.lastName.value == ""){ alert("Please provide your last name."); valid = false; } if(document.join.firstName.value == ""){ alert("Please provide your first name."); valid = false; } if(document.join.addressOne.value == ""){ alert("Please provide your address."); valid = false; } if(document.join.city.value == ""){ alert("Please provide your city name."); valid = false; } if(document.join.state.value == ""){ alert("Please select your state."); valid = false; } if(document.join.country.value == ""){ alert("Please select your country."); valid = false; } if(!zipCodeRe.test(document.join.zipCode.value)){ alert("Please provide a valid zip code."); valid = false; } if(!telephoneRe.test(document.join.phoneNumber.value)){ alert("Please provide a valid telephone number."); valid = false; } if(!emailRe.test(document.join.emailAddress.value)){ alert("Please provide a valid email address."); valid = false; } if(document.join.emailAddress.value != document.join.emailVerify.value){ alert("Email addresses do not match!"); valid = false; } if(document.join.password.value.length < 6){ alert("Password must be at least six characters long."); valid = false; } if(document.join.password.value != document.join.passwordVerify.value){ alert("Passwords do not match!"); valid = false; } if(document.join.secretQuestion.value == ""){ alert("Please provide your secret question."); valid = false; } if(document.join.secretQuestionAnswer.value == ""){ alert("Please provide answer to secret question."); valid = false; } return valid; } </script> </DIV> <DIV CLASS="body"> <FORM NAME="join" ACTION="http://cs-sun2000.uscupstate.edu/~student5/joinnow.php" METHOD="POST" onsubmit="return validate_form();"> <TABLE> <TR> <TD>Last Name: </TD> <TD> <INPUT TYPE="text" NAME=lastName MAXLENGTH="20" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>First Name: </TD> <TD> <INPUT TYPE="text" NAME=firstName MAXLENGTH="25" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>Address One: </TD> <TD> <INPUT TYPE="text" NAME="addressOne" MAXLENGTH="32" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>Address Two: </TD> <TD> <INPUT TYPE="text" NAME="addressTwo" MAXLENGTH="32" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>City: </TD> <TD> <INPUT TYPE ="text" NAME="city" MAXLENGTH="32" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>State: </TD> <TD> <SELECT NAME="state" CLASS="textfield"> <OPTION VALUE="">(STATE) </OPTION> <OPTION VALUE="AL"> ALABAMA </OPTION> <!--Just removed the rest so not to take up space.--> </TD> </TR> <TR> <TD>Country: </TD> <TD> <SELECT NAME="country" CLASS="textfield"> <OPTION VALUE="">(COUNTRY)</OPTION> <OPTION VALUE="ANDORRA"> ANDORRA </OPTION> <!--etc... etc... etc....--> <TR> <TD>Zip Code: </TD> <TD> <INPUT TYPE="text" NAME="zipCode" MAXLENGTH="10" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>Telephone: </TD> <TD> <INPUT TYPE="text" NAME="phoneNumber" MAXLENGTH="16" VALUE="" CLASS="textfield"><I><FONT SIZE="2">Ex. (555)123-4567 or 555-123-1234</FONT></I> </TD> </TR> <TR> <TD>Email: </TD> <TD> <INPUT TYPE="text" NAME="emailAddress" MAXLENGTH="100" VALUE="" CLASS="textfield"><I><FONT SIZE="2">Ex. [email protected]</FONT></I></TD> </TR> <TR> <TD>Verify Email: </TD> <TD> <INPUT TYPE="text" NAME="emailVerify" MAXLENGTH="100" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>Password: </TD> <TD> <INPUT TYPE="password" NAME="password" MAXLENGTH="64" VALUE="" CLASS="textfield"><I><FONT SIZE="2">Password must contain at least six characters.</FONT></I> </TD> </TR> <TR> <TD>Verify Password: </TD> <TD> <INPUT TYPE="password" NAME="passwordVerify" MAXLENGTH="64" VALUE="" CLASS="textfield"> </TD> </TR> <TR> <TD>Secret Question: </TD> <TD> <INPUT TYPE="text" NAME="secretQuestion" MAXLENGTH="100" STYLE="width:500px"; VALUE="" CLASS="textfield"><BR><I><FONT SIZE="2">Enter a question to be asked in case you forget your paswsword. (MAX LENGTH = 100 characters)</FONT></I></TD> </TR> <TR> <TD>Answer to Secret Question: </TD> <TD> <INPUT TYPE="text" NAME="secretQuestionAnswer" MAXLENGTH="100" STYLE="width:500px"; VALUE="" CLASS="textfield"><BR><I><FONT SIZE="2">Enter the answer to your secret question. (MAX LENGTH = 100 characters)</FONT></I> </TD> </TR> <TR> <TD> <BR><BR><INPUT TYPE="submit" NAME="send" VALUE="Submit"> <INPUT TYPE="reset" VALUE="Reset"> </TD> </TR> </TABLE> </FORM> </DIV> END; }else{ echo $line; }; // end else }; // end while ?> Link to comment https://forums.phpfreaks.com/topic/153541-php-mysql-user-registration/ Share on other sites More sharing options...
revraz Posted April 10, 2009 Share Posted April 10, 2009 Google "php and mysql tutorial" or read the tutorial from the main site here. Link to comment https://forums.phpfreaks.com/topic/153541-php-mysql-user-registration/#findComment-806797 Share on other sites More sharing options...
djcochran Posted April 11, 2009 Author Share Posted April 11, 2009 I can't seem to find the tutorial for this type of problem on this website... :-\ Link to comment https://forums.phpfreaks.com/topic/153541-php-mysql-user-registration/#findComment-806988 Share on other sites More sharing options...
revraz Posted April 11, 2009 Share Posted April 11, 2009 http://www.phpfreaks.com/tutorial/php-basic-database-handling Link to comment https://forums.phpfreaks.com/topic/153541-php-mysql-user-registration/#findComment-807059 Share on other sites More sharing options...
scarhand Posted April 11, 2009 Share Posted April 11, 2009 $username = mysql_real_escape_string($_POST['username']); $password = md5($_POST['password']); mysql_query("insert into members (username, password) values ('$username', '$password')"); Link to comment https://forums.phpfreaks.com/topic/153541-php-mysql-user-registration/#findComment-807127 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.