Jump to content

JP128

Members
  • Posts

    233
  • Joined

  • Last visited

Everything posted by JP128

  1. I put them on another page so that the page doesn't refresh. I am sure I could just make the value="<php echo $result_from_last_try; ?>"... I will do that later. I will make it check to see if it is a number before it tells you if its a year.
  2. you could make it to where before you insert anything add this <?php $sql_check = mysql_query("SELECT * FROM tbl_name limit 1"); while($check = mysql_fetch_assoc($sql_check)){ $storename = $check['store_name']; } if(mysql_num_rows(mysql_query("SELECT * FROM tbl_name WHERE store_name='$storename'")) < 1){ mysql_query("INSERT THE STORE NAME HERE"); } ?>
  3. I agree with Mmarif... I got confused when I read that.
  4. ok, I got that to work. I added in another page so that it doesnt refresh, and the users dont lose all the info that they did have typed, and I had to take out the empty(), because it gave me this error: PHP Fatal error: Can't use function return value in write context in... I replaced it with length(trim()). I also really like that way of error handling, I wouldn't have ever thought of that... it makes it very easy to add another kind of validation. Thanks for your help, but still one more question. How do I check to see that there are only numeric characters, and no alpha? edit ... I used preg_match, and made my own pattern here is the final register script: <?php function regAdd(){ dbConnect(); if (isset($_POST['submit'])){ $pattern = "/^(\d{4})$/"; $year = $_POST['year']; preg_match($pattern,$year,$match); $cur_year = date('Y'); $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $username = $_POST['username']; $email = $_POST['email']; $password = $_POST['password']; $password1 = $_POST['password1']; //Do all error checking like this if (strlen(trim($firstname)) == 0){ $error[1] = "You need to put a first name!"; } if (strlen(trim($lastname)) == 0){ $error[2] = "You need to put your last name!"; } if (strlen(trim($email)) == 0){ $error[3] = "You need to put an email!"; } if (strlen(trim($username)) == 0){ $error[4] = "You need to specify a username!"; } if (strlen(trim($password)) == 0){ $error[5] = "You need to specify a password!"; } if (strlen(trim($password1)) == 0){ $error[6] = "You need to confirm the password!"; } if (strlen(trim($year)) == 0){ $error[7] = "You need to specify a year!"; } if ($password != $password1){ $error[8] = "Your passwords didn't match!"; } if (!isset($match[1])){ $error[9] = $year." is not a valid year!"; } if ($year >= $cur_year){ $error[10] = "You cannot be born in the future!"; } // if (){ $error[] = ""; } //add another error // if (){ $error[] = ""; } //add another error if (!empty($error)){ foreach ($error as $message){ echo '<li>'.$message.'</li>'; } ?> <br> <title>Error while trying to register.</title> <button onClick='history.go(-1);'>Fill in the rest</button> <?php } else { echo "<title>Registered!</title>"; $dob = $_POST['month'] . "-" . $_POST['day'] . "-" . $match[1]; //Insert data into database, they filled the form out correctly. $sqlFind = mysql_query("SELECT ****,**** FROM **** WHERE ****='$****' OR ****='$****'"); $numsqlFind = mysql_num_rows($sqlFind); if($numsqlFind > 0){ echo"<font color=red><center><h3>That username, or email was already used, cannot continue!</h3></center></font>"; regForm(); exit; } else { mysql_query("insert into **** values('','$****','$****','$****,'$'****',****,'$****','****',****,'****','****','****','****','****')") or die(mysql_error()); echo"Welcome, $firstname $lastname. Your username is $username. Your email is $email. <a href=http://jp128.mooo.com/login.php>Login</a>."; mysql_query("insert into **** values('','****','$username','Welcome!','Welcome to jp128.mooo.com.',null,'','')"); } } } } ?> Thank you guys for all of your help... If you want to try to find more errors, just look, and if you see any just post back here so I can fix them... However for now, I will put SOLVED
  5. Well, I am not sure whats wrong, but I did see this: $id = $_POST['id']; $username = $_SESSION['username']; if ($_FILES["file"]["type"] == "image/gif") || $_FILES["file"]["type"] == "image/pjpeg") || $_FILES["file"]["type"] == "image/png") || $_FILES["file"]["type"] == "image/bmp") || $_FILES["file"]["type"] == "movie/swf") || $_FILES["file"]["type"] == "image/jpeg") || $_FILES["file"]["type"] == "music/mp3") || $_FILES["file"]["type"] == "music/wma") && ($_FILES["file"]["size"] < 5000)) you could try to change that to: $id = $_POST['id']; $username = $_SESSION['username']; if (($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/pjpeg") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/bmp") || ($_FILES["file"]["type"] == "movie/swf") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "music/mp3") || ($_FILES["file"]["type"] == "music/wma") && ($_FILES["file"]["size"] < 5000))
  6. What would be a different way that I could validate the form? You've already seen the red text part, but what would you do to make it better? Just asking for ideas, not an entire script. form: firstname lastname email username password confirmpassword those are the ones that I need to validate.
  7. this is my whole function for the registry form. function regForm(){ echo ' <script language=javascript> var check = 1; function checkForm(){ if(document.register.firstname.value.length == 0){ alert("You forgot to fill out the first name textbox"); check = 0; return false; } else if(document.register.lastname.value.length == 0){ alert("You forgot to fill out the last name textbox"); check = 0; return false; } else if(document.register.email.value.length == 0){ alert("You forgot to fill out the email textbox"); check = 0; return false; } else if(document.register.year.value.length == 0){ alert("You forgot to fill out the year textbox"); check = 0; return false; } else if(document.register.username.value.length == 0){ alert("You forgot to fill out the username textbox"); check = 0; return false; } else if(document.register.password.value.length == 0){ alert("You forgot to fill out the password textbox"); check = 0; return false; } else if(document.register.password1.value.length == 0){ alert("You forgot to fill out the confirm password textbox"); check = 0; return false; } else if(document.register.password.value != document.register.password1.value){ alert("Your passwords do not match"); check = 0; return false; } else{ document.register.submit(); } } </script> '; echo"<form name='register' method=\"post\" action=\"\" onSubmit='checkForm();'> <center> <table border=\"1\"> <tr> <td colspan=2><center>Register</center></td> </tr> <tr> <td width=\"121\">First Name:</td> <td width=\"172\"><input type=text name=firstname></td> </tr> <tr> <td>Last Name:</td> <td><input type=text name=lastname></td> </tr> <tr> <td>E-mail:</td> <td><input type=text name=email></td> </tr> <tr> <td>Date of Birth: </td> <td><select name=\"month\" id=\"month\"> <option value=\"01\" selected>Jan</option> <option value=\"02\">Feb</option> <option value=\"03\">Mar</option> <option value=\"04\">Apr</option> <option value=\"05\">May</option> <option value=\"06\">Jun</option> <option value=\"07\">Jul</option> <option value=\"08\">Aug</option> <option value=\"09\">Sep</option> <option value=\"10\">Oct</option> <option value=\"11\">Nov</option> <option value=\"12\">Dec</option> </select> <select name=\"day\" id=\"day\"> <option value=\"01\" selected>01</option> <option value=\"02\">02</option> <option value=\"02\">03</option> <option value=\"04\">04</option> <option value=\"05\">05</option> <option value=\"06\">06</option> <option value=\"07\">07</option> <option value=\"08\">08</option> <option value=\"09\">09</option> <option value=\"10\">10</option> <option value=\"11\">11</option> <option value=\"12\">12</option> <option value=\"13\">13</option> <option value=\"14\">14</option> <option value=\"15\">15</option> <option value=\"16\">16</option> <option value=\"17\">17</option> <option value=\"18\">18</option> <option value=\"19\">19</option> <option value=\"20\">20</option> <option value=\"21\">21</option> <option value=\"22\">22</option> <option value=\"23\">23</option> <option value=\"24\">24</option> <option value=\"25\">25</option> <option value=\"26\">26</option> <option value=\"27\">27</option> <option value=\"28\">28</option> <option value=\"29\">29</option> <option value=\"30\">30</option> <option value=\"31\">31</option> </select> <input name=\"year\" type=\"text\" id=\"year\" size=\"5\" maxlength=\"4\"></td> </tr> <tr> <td>Username:</td> <td><input type=text name=username></td> </tr> <tr> <td>Password:</td> <td><input type=password name=password></td> </tr> <tr> <td>Re-Type Password:</td><td><input type=password name=password1></td> </tr> <tr> <td><div align=\"right\"> <input type='submit' value='Register'> </div></td> <td><input name=\"reset\" type=reset></td> </tr> <tr> <td colspan='2'><div align='right'>©2006 John-Paul Ensign</div></td> </tr> </table> </center> </form>"; exit; }
  8. you were missing a "{", that fixed that alerting problem. it alerts, but still submits
  9. kk, I changed it. Now, it submits it without even alerting whats missing =)
  10. kk, I changed the script... with the return false, it doesnt tell everything that is wrong.... and it still submits
  11. hah... it might be funny, but making was a huge learning experience . I have only made a dent in the php language... I want to learn a lot more =P.... I dont know a ton of javascript.. what does return false do??
  12. .... something is wrong with my javascript... it still submits the form, even when it isnt supposed to... here is the javascript code.. <script language=javascript> var check = 1; function checkForm(){ if(document.register.firstname.value.length == 0){ alert("You forgot to fill out the first name textbox"); check = 0; } if(document.register.lastname.value.length == 0){ alert("You forgot to fill out the last name textbox"); check = 0; } if(document.register.email.value.length == 0){ alert("You forgot to fill out the email textbox"); check = 0; } if(document.register.year.value.length == 0){ alert("You forgot to fill out the year textbox"); check = 0; } if(document.register.username.value.length == 0){ alert("You forgot to fill out the username textbox"); check = 0; } if(document.register.password.value.length == 0){ alert("You forgot to fill out the password textbox"); check = 0; } if(document.register.password1.value.length == 0){ alert("You forgot to fill out the confirm password textbox"); check = 0; } if(document.register.password.value != document.register.password1.value){ alert("Your passwords do not match"); check = 0; } if(check == 1){ document.register.submit(); } } </script> and, it goes through the check twice....
  13. Yea, I am redoing the whole thing now... I made this back when I was a noob with php... I am still learning alot..
  14. lol... I could do that.... I could even change it for you... Do you have a messenger? yahoo, msn, or aim?
  15. ok, I am working on a better register script.
  16. Yea, you probably have a form that is being submitted to that page... <form method="post(goes through site not showing you) or get(goes on the address, adding ?varname=varvalue" action="">
  17. on the register form? yea... It just checks them from the top, going down. if one is missing, then stop, and say what is missing.. .I need to make it better lol...
  18. echo "<a href='",$sPHPSELF,"?edit=",$result['name'],"'>",$result['name'],"</a>"; try that... you have been missing the = sign
  19. Hey I have been creating a php website, and it is going well. I have a register/login, and now making a PM system. http://jp128.mooo.com/ that is the site... if you have AIM, add me.. EvilBore or Stropfo, and tell me what you think otherwise just post it back here... If you see anything that is wrong, I'd like to know =P Thanks, John
  20. Thanks I got it to work. I just had to change the arrangement of the alert, and passed variable... I also put in a password check. Thanks for your help!
  21. http://static.photobucket.com/include/js/copy-code.js thats photobuckets copy code...
  22. And by the way... it only works with IE explorer =/
  23. <html> <head> <script type="text/javascript"> function CopyToClipboard() { CopiedTxt = document.selection.createRange(); CopiedTxt.execCommand("Copy"); } </script> </head> <body> <form name="Form1"> <input type=text name="textbox"> <br /> <input type="button" onClick="CopyToClipboard()" value="Copy to clipboard" /> </form> </body> </html>
  24. hmm, it still sends it through...
×
×
  • 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.