Jump to content

Bounty

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

Everything posted by Bounty

  1. I didn't notice that :S Thanks a lot believe or not topic is solved it works like a Swiss watch
  2. It works almost perfectly but it shows error at: $errors[] = $error; Output:
  3. So i should add it after this line: if( (isset($_POST['submitted']) && !empty($errors)) || !isset($_POST['submitted']) ) { But it wont work...
  4. Fixed that...it was a type mistake...now the final thing... I tried to add [action=do_reg.php] inside form brackets but it wont work..it just jumps over whole script to do_reg.php...so how should i continue the registration after the checking fields...should i add [include 'do_reg.php';] at the end of the php before }?
  5. I really don't remember erasing that :S Anyhow it works now all the way to: if( !empty($_POST['password2']) ) { // same validations as in name, above. if($_POST['password2'] != $_POST['password']) { $error = 'Passwords do not match.' . $errors[] = $error; } } else { $errors[] = 'Confirm your password.'; } Script always jumps to this error "Confirm your password." even if: [password] => abc [pass_conf] => abc
  6. <?php // Uncomment next line for debug. echo '<pre>'; print_r($_POST); echo '</pre>'; if( isset($_POST['submitted']) && $_POST['submitted'] == 'yes' ) { //check for hidden field value to indicate form has been submitted $errors = array(); // initialize an array to hold validation errors $_POST = array_map('trim', $_POST); // trim all $_POST array values if( !empty($_POST['username']) ) { // validate the name field if( !ctype_alnum($_POST['username']) ) { $errors[] = 'Name must be alphabetic characters only.'; // if name has non alpha chars, store error } if( strlen($_POST['username']) < 3 || strlen($_POST['username'] > 20) ) { $errors[] = 'Name must be from 3 to 20 characters.'; // if name has too many/few chars, store error } } else { $errors[] = 'Name is a required field.'; // if name is empty, store error } if( !empty($_POST['password']) ) { // same validations as in name, above. if( !ctype_alnum($_POST['password']) ) { $errors[] = 'Password must be alphanumeric charachters only.'; } if( strlen($_POST['password']) < 3 || strlen($_POST['password']) > 20 ) { $error = 'Password must be from 3 to 20 charachters. It is currently ' . strlen($_POST['password']) . ' digit'; $errors[] = $error; } } else { $errors[] = 'Password is a required field.'; } if( !empty($_POST['password2']) ) { // same validations as in name, above. if($_POST['password2'] != $_POST['password']) { $error = 'Passwords do not match.' . $errors[] = $error; } } else { $errors[] = 'Confirm your password.'; } if(empty($_POST['email']) ) { // same validations as in name, above. $errors[] = 'Email is a required field.'; } if( !empty($errors) ) { // if the $errors array is not empty, display the errors to allow the user to correct them and resubmit the form echo "<font color=\"red\">The following errors were detected:<br>"; echo implode("<br>\n", $errors); echo '</font>'; } } if( (isset($_POST['submitted']) && !empty($errors)) || !isset($_POST['submitted']) ) { ?> <html> <head> <title>Register!</title> </head> <body> <table border="5" align="center" cellpadding="5" cellspacing="5" bordercolor="#333333"> <tr> <td width="400" align="left" valign="middle"> <table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#333333"> <tr> <td align="left" valign="middle"> <form method="post" id="info"> <h2 align="center" class="style10">Register:</h2> <div id="username-wrap" class="slider"> <label for="username">Username:</label> <input type="text" id="name" name="username" autocomplete="off" style="background-color: #000000; color: #999999;" /> </div><!--/#username-wrap--> <div id="pass-wrap" class="slider"> <label for="password">Password:</label> <input type="password" id="pass" name="password" autocomplete="off" style="background-color: #000000; color: #999999;" /> </div><!--/#password-wrap--> <div id="pass2-wrap" class="slider"> <label for="password2">Repeat:</label> <input type="password" id="pass2" name="pass_conf" autocomplete="off" style="background-color: #000000; color: #999999;" /> </div><!--/#password2-wrap--> <div id="email-wrap" class="slider"> <label for="email">Email:</label> <input type="text" id="email" name="email" autocomplete="off" style="background-color: #000000; color: #999999;" /> </div><!--/#email-wrap--> <div align="center"> <input type="submit" id="btn" name="submit" value="Submit" autocomplete="off" style="font-size: 17px; font-weight: bold; background-color: #000000; color: #CCCCCC;"/> </div> </form></td> </tr> </table> </td> </tr> </table> </body> </html> <?php } ?> Sorry for bothering so much :S
  7. Please use [ code ] & [ /code ] when inserting code...
  8. @Pikachu When i do this: <?php //php code { <html> //html block </html> } ?> I get this error: 54 line = <html> And when i do this: <?php //php code { ?> <html> //html block </html> <?php } ?> It doesn't show any errors but it wont echo errors...i just echoes debug lines... @aabid Thanks thats useful info
  9. Ok,forget about last post,i get it all now...anyhow i made it work on simple html form but i can't add this php to my form on my page: <?php // Uncomment next line for debug. echo '<pre>'; print_r($_POST); echo '</pre>'; if( isset($_POST['submitted']) && $_POST['submitted'] == 'yes' ) { //check for hidden field value to indicate form has been submitted $errors = array(); // initialize an array to hold validation errors $_POST = array_map('trim', $_POST); // trim all $_POST array values if( !empty($_POST['username']) ) { // validate the name field if( !ctype_alnum($_POST['username']) ) { $errors[] = 'Name must be alphabetic characters only.'; // if name has non alpha chars, store error } if( strlen($_POST['username']) < 3 || strlen($_POST['username'] > 20) ) { $errors[] = 'Name must be from 3 to 20 characters.'; // if name has too many/few chars, store error } } else { $errors[] = 'Name is a required field.'; // if name is empty, store error } if( !empty($_POST['password']) ) { // same validations as in name, above. if( !ctype_alnum($_POST['password']) ) { $errors[] = 'Password must be alphanumeric charachters only.'; } if( strlen($_POST['password']) < 3 || strlen($_POST['password']) > 20 ) { $error = 'Password must be from 3 to 20 charachters. It is currently ' . strlen($_POST['password']) . ' digit'; $errors[] = $error; } } else { $errors[] = 'Password is a required field.'; } if( !empty($_POST['password2']) ) { // same validations as in name, above. if($_POST['password2'] != $_POST['password']) { $error = 'Passwords do not match.' . $errors[] = $error; } } else { $errors[] = 'Confirm your password.'; } if(empty($_POST['email']) ) { // same validations as in name, above. $errors[] = 'Email is a required field.'; } if( !empty($errors) ) { // if the $errors array is not empty, display the errors to allow the user to correct them and resubmit the form echo "<font color=\"red\">The following errors were detected:<br>"; echo implode("<br>\n", $errors); echo '</font>'; } } if( (isset($_POST['submitted']) && !empty($errors)) || !isset($_POST['submitted']) ) { ?> <html> <head> <title>Register!</title> </head> <body> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <table border="5" align="center" cellpadding="5" cellspacing="5" bordercolor="#333333"> <tr> <td width="400" align="left" valign="middle"> <table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#333333"> <tr> <td align="left" valign="middle"> <form action="do_reg.php" method="post" id="info"> <h2 align="center" class="style10">Register:</h2> <div id="username-wrap" class="slider"> <label for="username">Username:</label> <input type="text" id="name" name="username" autocomplete="off" style="background-color: #000000; color: #999999;" /> </div><!--/#username-wrap--> <div id="pass-wrap" class="slider"> <label for="password">Password:</label> <input type="password" id="pass" name="password" autocomplete="off" style="background-color: #000000; color: #999999;" /> </div><!--/#password-wrap--> <div id="pass2-wrap" class="slider"> <label for="password2">Repeat:</label> <input type="password" id="pass2" name="pass_conf" autocomplete="off" style="background-color: #000000; color: #999999;" /> </div><!--/#password2-wrap--> <div id="email-wrap" class="slider"> <label for="email">Email:</label> <input type="text" id="email" name="email" autocomplete="off" style="background-color: #000000; color: #999999;" /> </div><!--/#email-wrap--> <div align="center"> <input type=hidden name=ip value='<?php echo $ip ?>'/> <input type="submit" id="btn" name="submit" value="Submit" autocomplete="off" style="font-size: 17px; font-weight: bold; background-color: #000000; color: #CCCCCC;"/> </div> </form></td> </tr> </table> </td> </tr> </table> </body> </html> I get error on last line (</html>) how to make this work??? :S
  10. Okay thank you for your time ill search for salt password...Topic solved
  11. I think that's all i need...just could you guide me through the code...i understand most of it but..what would commented part of the code do? What this first line means? and what should 'triming' mean? if( isset($_POST['submitted']) && $_POST['submitted'] == 'yes' ) { $errors = array(); $_POST = array_map('trim', $_POST); And this one if( (isset($_POST['submitted']) && !empty($errors)) || !isset($_POST['submitted']) ) { ?> And i should add to <form method="post"> action="do_reg.php" ?
  12. I needed to backslash quotes in echo line...it works now just there is an error :S After alert message shows up and after i press ok it reloads the page as nothing happened,on the first sight it looks great,but i've just checked my database and saw that it actually crates a user with empty fields (even if the page is redirected)... Can it be made for script to stop at one place? like: if($formGood != ''){ echo "<script>alert('$formGood');window.location=\"register.php\";</script>"; //stop here! }
  13. Works great even if i do not understand the script but nvm about that...anyhow could a page be reloaded after ok is pressed? Thanks for the help so far
  14. Similar errors as the minute ago...couldn't it be done via my first script?
  15. I think you didn't understand what i wanna achieve... If just email and username i empty and rest are filled it should alert error "Username and email fields are empty.." (for each false different error and after user clicks on "ok" button reload page,or just stop script...
  16. Ok so i have registration page on my webs but i didn't work on empty fields so how could i check all fields? //if no name if(!$name){ $error = "Username missing."; } //if no pass if($pass == false){ $error = "$error,Password missing"; } //if no pass conf if($pass_conf == false) { $error = "$error,Pass conf missing."; } //if no email if($email == false){ $error = "$error,Email missing."; } //pass conf if($pass != $pass_conf){ $error = "$error,Passwords do not match."; } echo "<script>alert('$error');</script>;"; //header("Location: register.php"); My script gives same results every time (even if i fill any of fields)...also if i un-comment header command it wont show alert..it just reloads the page :'( So can anyone help me with this? Thanks..
  17. Sorry but i don't rly understand...salt? rainbow tables? How should i compare plain text password to an md5 one,instead of this: $password = md5($password); if ($password!=$password_db) echo "Incorect password!"; it failed every time..?
  18. Okay i got some info about byethost hosting that are not very cheerful,SMTP can be configured just if you are premium user witch obviously I am not...i'm quiting of that part of the script until i get my premium host and domain... Anyhow...i commented out all scripts that has anything to do with mail function and system works... Although i still have some questions... My do_login.php script now looks like this: <?php include 'connection.php'; // $session_username = $_SESSION['username']; if($_POST['login']) { //get form data $username = $_POST['username']; $password = $_POST['password']; } if(!$username||!$password) echo "Username and password missing!"; else { //login $login = mysql_query("SELECT * FROM users WHERE username='$username'"); } if (mysql_num_rows($login)==0) echo "No such user!"; else { while ($login_row = mysql_fetch_assoc($login)) { $password_db = $login_row['password']; //$password = md5($password); if ($password!=$password_db) echo "Incorect password!"; else { //check if active $active = $login_row['active']; $email = $login_row['email']; if ($active==0) echo "You haven't activated your account, please check your email ($email) for activation!"; else { $_SESSION['username']=$username; //assign session // header("Location: index.php");//refresh echo "DONE!"; } } } } ?> It didn't worked before because this line: $password = md5($password); if ($password!=$password_db) echo "Incorect password!"; Real password and md5 coded password didn't match obviously (thats why i commented that line too)..but why? Shouldn't md5 coding be for security reasons? If so how could i add it to my script,but the match must be true?... And should i add md5 coding to register page as well?
  19. As i said i copied all files from localhost server to byethost (free hosting) that should do the trick...but it doesn't :S
  20. Edited do_reg.php and uploaded to test byethost Still keeps ignoring mail function and jumps to error :"Error,what a shame!" :/ <?php include 'connection.php'; //grab data from form $name = $_POST['username']; $pass = $_POST['password']; $pass_conf = $_POST['pass_conf']; $email = $_POST['email']; $ip = $_POST['ip']; //if else if($name == false || $pass == false || $pass_conf == false || $email == false){ echo "Please fill in all the required fields."; }; if($pass != $pass_conf){ echo "Blah..Passwords do not match."; }else{ //generate random code $code = rand(11111111,99999999); //send email $subject = "Activate your account"; $headers = "From: admin@hyperlink.com"; $body = "Hello $name,\n\nYou registered and need to activate your account. Click the link below or paste it into the URL bar of your browser\n\n http://localhot/login/activate.php?code=$code\n\nThanks!"; if (mail($email,$subject,$body,$headers)) { $sql = mysql_query("INSERT INTO users (username,password,email,code,active,ip) VALUES('$name','$pass','$email','$code',0,'$ip')") or die(mysql_error()); $result = mysql_query($sql); echo "Thank you for registering! But your account is not still active :'( Please check your email ($email) for activation code! "; } else { echo "Error,what a shame!"; } }; ?>
  21. Okay second error solved but i don't get what do i have to add to fix first one? :/
×
×
  • 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.