Jump to content

codeminer

Members
  • Content count

    22
  • Joined

  • Last visited

Community Reputation

0 Neutral

About codeminer

  • Rank
    Newbie

Profile Information

  • Gender
    Male
  • Location
    earth
  • Interests
    php,css,html,sql,xampp set-up

Previous Fields

  • Languages
    php,css,html,sql,xampp set-up
  1. form validation

    I thought this worked ,it doesn/'t hash the pass, It puts the hash in the data base but it fires prematurely it causes the input field to be fill before the user input is served . just need to keep pounding .hopefully ill get a break through, trial an error unfortunately mostly error
  2. form validation

    thank you for your expert advise. I managed to convert the password into the options array prior to inserting in to db using this code. It works!!!YA.THANK YOU //password if (empty($_POST["password"])) { $passwordErr = "password word is required"; } else { $password = test_input($_POST["password"]); //changed the regular expression you can add up to 60 charecters if (!preg_match("/^(?=[-_a-zA-Z0-9]*?[A-Z])(?=[-_a-zA-Z0-9]*?[a-z])(?=[-_a-zA-Z0-9]*?[0-9])\S{0,60}/",$password)) { $password_Err = "<br><P>Password must be a mixure of no# and letters containing upper & lower case charecters</P>"; } } // changed the name of password to password_hash call the $options array this is coverting the password prior to getting to db it works $options = [ 'cost' => 9, 'salt' => mcrypt_create_iv(22, MCRYPT_DEV_URANDOM), ]; $password = password_hash($password, PASSWORD_BCRYPT, array( '$options' ));
  3. form validation

    I read your article that you put up a while back on form page mode very helpful and in depth in fact if I would have discovered sooner I wouldn't have post this I know im just printing the hash out on the page .I Relies that it needs to be defined in the insert statement .what im trying to learn is how to put it in the insert statement so that hashing of the password is accomplished in db . as far as the specialchars i never used them before i 'm trying to learn security . here is my insert file <?php $servername = ""; $username = ""; $password = ""; $dbname = ""; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); //____________________________________________ //trying to understand how to put this in the statement }else{ $options = [ 'cost' => 9, 'salt' => mcrypt_create_iv(22, MCRYPT_DEV_URANDOM), ]; $password = password_hash( "password" ,PASSWORD_BCRYPT, $options); //_______________________________________ $sql = "INSERT INTO users (username, password,email,website,comment,gender) VALUES ('$_POST[username]', '$_POST[password]', '$_POST[email]', '$_POST[website]', '$_POST[comment]', '$_POST[gender]')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully, <a href = 'http://127.0.0.1/A'>Click here to continue</a>"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } } $conn->close();
  4. form validation

    sorry about this duplication im just not familiar with this editor I can't seem to locate the delete button
  5. form validation

  6. form validation

    <!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php /** * Note that the salt here is randomly generated. * Never use a static salt or one that is not randomly generated. * * For the VAST majority of use-cases, let password_hash generate the salt randomly for you */ // define variables and set to empty values $usernameErr = $passwordErr = $firstnameErr = $emailErr = $genderErr = $websiteErr = ""; $username = $password = $firstname = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["username"])) { $usernameErr = "UserName is required"; } else { $username = test_input($_POST["username"]); if (!preg_match("/^[a-zA-Z ]*$/",$username)) { $usernameErr = "Only letters and white space allowed"; } } if (empty($_POST["password"])) { $passwordErr = "password word is required"; } else { $password = test_input($_POST["password"]); if (!preg_match("/^(?=[-_a-zA-Z0-9]*?[A-Z])(?=[-_a-zA-Z0-9]*?[a-z])(?=[-_a-zA-Z0-9]*?[0-9])\S{8,}/",$password)) { $passwordErr = "<br>Password must be a mixure of <br>no# and letters containing <br>upper & lower case letters <br>at least 8 charecters<br>long"; } } if (empty($_POST["firstname"])) { $firstnameErr = "FirstName is required"; } else { $firstname = test_input($_POST["firstname"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$firstname)) { $firstnameErr = "Only letters and white space allowed"; } } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address is well-formed if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } } if (empty($_POST["website"])) { $website = ""; } else { $website = test_input($_POST["website"]); // check if URL address syntax is valid (this regular expression also allows dashes in the URL) if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) { $websiteErr = "Invalid URL"; } } if (empty($_POST["comment"])) { $comment = ""; } else { $comment = test_input($_POST["comment"]); } if (empty($_POST["gender"])) { $genderErr = "Gender is required"; } else { $gender = test_input($_POST["gender"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <h2>PHP Form Validation Example</h2> <p><span class="error">* Required Fields</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Username:<br/> <input type="text" name="username" value="<?php echo $username;?>"> <span class="error">* <?php echo $usernameErr;?></span> <br><br> Password:<br/> <input type="password" name="password" value="<?php echo $password;?> ?> "> <span class="error">* <?php echo $passwordErr;?></span> <br><br> Firstname:<br/> <input type="text" name="firstname" value="<?php echo $firstname;?>"> <span class="error">* <?php echo $firstnameErr;?></span> <br><br> E-mail:<br/> <input type="text" name="email" value="<?php echo $email;?>"> <span class="error">* <?php echo $emailErr;?></span> <br><br> Website:<br/> <input type="text" name="website" value="<?php echo $website;?>"> <span class="error"><?php echo $websiteErr;?></span> <br><br> Comment:<br/> <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea> <br><br> Gender:<br/> <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female">Female <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male">Male <span class="error">* <?php echo $genderErr;?></span> <br><br> <input type = "reset" name = "reset"/> | <input type="submit" name="submit" value="Submit"> </form> <h2><?php echo "WELLCOM!";?> <?php echo $username;?></h2> <?php $options = [ 'cost' => 9, 'salt' => mcrypt_create_iv(22, MCRYPT_DEV_URANDOM), ]; echo password_hash("rasmuslerdorf", PASSWORD_BCRYPT, $options); echo "<br>"; echo $firstname; echo "<br>"; echo $email; echo "<br>"; echo $website; echo "<br>"; echo $comment; echo "<br>"; echo $gender; ?> </body> </html> Hello I need some advise on this need to make sure this is correct . I took this form from w3shools a long time ago. I modified it with regular expressions went to php.net, pick the hash function manipulated the code a little bit just need to make sure it gonna fly thank you in advance
  7. easyphp can not connect to db

    <?php $servername = "localhost"; $username = "YOUR USERNAME"; $password = "LEAVE BLANK IF YOU HAVENT CREATED PASSWORD"; // if you don't have a db just comment out $dbname //you will also need to remove it from $conn=new mysqli //(make sure to take off the comma at the end of password) $dbname = "YOUR DB NAME"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // you can remove the echo and add whichever kind of STATEMENT you like echo "Connected successfully"; mysqli_close($conn); ?>
  8. How can I put blur on the image?

    /*this will give you blurred border around your div which overlapse your photo dont know if this helps not the best solution but it works*/ body{ background-image: url( "YOUR PHOTO HEREj.jpg"); background-repeat:no-repeat; background-color: #fff000; background-size: 100% 100vh ; opacity: 1; border:1px #000; border-radius:12px; box-shadow:10px 10px 50px 20px #AAAAFF inset; }
  9. Trying to round the courners of my submit button

    no problem, i hope you getter done!
  10. Small Group Projects

    I think it would be great to have small group projects .We could build login system; with air tight state of the art security, photo gallary's, audio gallery's. I think it would be a great tool for learning web development . Just a thought.
  11. Trying to round the courners of my submit button

    <head> <style type="text/css"> div.af-clear { border-radius: 20px; } </style> </head> <head> <style type="text/css"> div#af-clear { border-radius: 20px; } /*______________________________________________________________________________ I tested this, it works! add the code below to your css */ ___________________________________________________________________________*/ input[type=submit] { border-radius: 20px; border: 0; width: 80px; height:25px;... } /*________________________________________________*/ </style> </head> <head> <style> div.af-clear { border-radius: 20px; } </style> <form accept-charset="UTF-8" action="https://www.aweber.com/scripts/addlead.pl" class="af-form-wrapper" method="post" target="_blank"> <div pbzloc="39" style="display: none"><input name="meta_web_form_id" type="hidden" value="1991411101" /> <input name="meta_split_id" type="hidden" /> <input name="listname" type="hidden" value="awlist4806168" /> <input id="redirect_41e503e55e268d841032ed3217e9f27e" name="redirect" type="hidden" value="http://launchpointforgrowingtaller.info/thankyou.html" /> <input name="meta_adtracking" type="hidden" value="Grow_Taller_Form" /> <input name="meta_message" type="hidden" value="1" /> <input name="meta_required" type="hidden" value="name,email" /> <input name="meta_tooltip" type="hidden" /></div> <div class="af-form" id="af-form-1991411101"> <div class="af-header" id="af-header-1991411101"> <div class="bodyText"> <p pbzloc="17">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="font-size: 26px"><strong><span pbzloc="16" style="color: #ff0000"><label class="previewLabel" for="awf_field-93026630">First Name: </label></span></strong></span></p> </div> </div> <div class="af-body af-standards" id="af-body-1991411101"> <div class="af-element"> <div class="af-textWrap" pbzloc="15" style="text-align: center"><input class="text" id="awf_field-93026630" name="name" onblur="if (this.value == '') { this.value='';} " onfocus=" if (this.value == '') { this.value = ''; }" pbzloc="32" size="16" style="height: 34px; width: 254px" tabindex="500" type="text" /></div> <div class="af-clear" style="text-align: center"></div> </div> <div class="af-element"> <p style="text-align: center"><span style="font-size: 26px"><strong><span pbzloc="18" style="color: #ff0000">&nbsp;<label class="previewLabel" for="awf_field-93026631" pbzloc="43">Email: </label></span></strong></span></p> <div class="af-textWrap" pbzloc="42" style="text-align: center"><input class="text" id="awf_field-93026631" name="email" onblur="if (this.value == '') { this.value='';} " onfocus=" if (this.value == '') { this.value = ''; }" pbzloc="33" style="height: 35px; width: 254px" tabindex="501" type="text" /></div> <div class="af-clear" pbzloc="12" style="text-align: center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div> </div> <div class="af-element buttonContainer"> <div class="af-clear" pbzloc="19" style="text-align: center">&nbsp; <span style="color: #ff0000"><input class="submit" name="submit" pbzloc="50" size="1" style="font-size: 1.2em; height: 51px; width: 143px; color: white; background-color: #ff0000" tabindex="502" type="submit" value="Submit" /></span></div> </div> <div class="af-element privacyPolicy" style="text-align: center"> <p>&nbsp;&nbsp;&nbsp; We respect your <a href="https://www.aweber.com/permission.htm" rel="nofollow" target="_blank" title="Privacy Policy">email privacy</a></p> <div class="af-clear" pbzloc="51"></div> </div> </div> <div class="af-footer" id="af-footer-1991411101"> <div class="bodyText"></div> </div> </div> <div style="display: none"><img alt="" src="https://forms.aweber.com/form/displays.htm?id=jJycjCyMjIwMjA==" /></div> </form>
  12. Auto Registering Files

    this has been very helpfull i been working on this all day i did check out the glob concept at php.net they have a lot of examples . i need to run some through the editor see what they do . i will all so check out your link . i would really like to come up with something i think it would benifit every one to have a tool like that. save a lot of time .
  13. Auto Registering Files

    i tried using this i add variables to create the characters || $ == "" i was able to wrap each file in the proper syntaxes when i call it on the script i kept getting those charming error messages. i dont know what a glob is i ll go look it up . thanks again <?php //like fopen/fread/fclose //opendir() //readdir() //closedir() $dir = "."; if(is_dir($dir)){ if($dir_handle = opendir($dir)){ while($filename = readdir($dir_handle)){ echo "filename:{$filename}<br/>"; } //closedir($dir_handle); //} //} echo "<hr/>"; //scandir():reads all file names into an array if(is_dir($dir)){ $dir_array = scandir($dir); foreach($dir_array as $file){ if(stripos($file, '.')> 0){ echo "filename:{$file}<br/>"; } } } closedir($dir_handle); } } ?> hanks i will try it
  14. Trying to round the courners of my submit button

    this works two input[type=submit] { border-radius: 5px; border: 0; width: 80px; height:25px;... }
  15. Auto Registering Files

    Im wondering if there is a way to to automaticly register a php file , so it wont show up when reading a directory. Doing this || $file == "somefile.php" after ten or twenty time gets to be grievious
×