Jump to content

Bounty

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

About Bounty

  • Birthday 10/30/1993

Profile Information

  • Gender
    Male
  • Location
    Serbia

Bounty's Achievements

Member

Member (2/5)

0

Reputation

  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
×
×
  • 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.