Jump to content

Glese

Members
  • Posts

    166
  • Joined

  • Last visited

    Never

Everything posted by Glese

  1. Thanks a lot, and you are right, linear thinking helps.
  2. I do want to validate a password input field to only allow numbers and letters without special character and spaces, and I also do want the same for the name input field. Since the old fashioned ways are deprecated. How would one approach to solve this issue the new way?
  3. Glese

    Fixed header

    Would be good if you could post an example.
  4. <form method="post" action=""> <input type="input" name="user_name" /> <input type="submit" name="user_name_submit" /> </form> <?php if(!empty($_POST['user_name'])) $user_name = $_POST['user_name']; if(isset($_POST['user_name_submit'])) { $user_name_submit = $_POST['user_name_submit']; } $user_name_preg_match = preg_match('/[a-zA-Z0-9]/', $user_name); if($user_name_preg_match) { echo 'true'; } else { echo 'false'; } ?> In this script I am getting the notice: Notice: Undefined variable: user_name Any suggestions how to avoid the notice in this case?
  5. It describes a section (or code block) in which code becomes executed. Imagine the execution of a PHP file going down linear from top to bottom, line by line by line - line 1, line 2, line 3 and so on. Since PHP is a loosely written programming language, which means that the position of the code are not hard coded into the language, the interpretation of the file needs to know where a code block starts and where it ends, thus this, which I called a section, describes as follows: if (isset($variable)) { // if condition met, execute code } a code block, which is in this example an if statement, which contains code that needs to be executed as soon as the condition is met. At the same time the interpretation needs to know where the container of the code block exactly ends and a new code block starts, and that is what the curly braces are for.
  6. I am trying to use the new way of validating the entered email in a register form. /* REGISTER FORM */ // check if submit button has been clicked if (isset($_POST['submit_signup'])) { // process and assign variables after post submit button has been clicked $user_email = strip_tags(trim($_POST['email'])); $user_email = filter_var($user_email, FILTER_VALIDATE_EMAIL); $nickname = strip_tags(trim($_POST['nickname'])); $password = $_POST['password']; $repassword = $_POST['repassword']; $month = $_REQUEST['month']; $day = $_REQUEST['day']; $year = $_REQUEST['year']; $dob = $year . "-" . $month . "-" . $day; $find_us_question = strip_tags(trim($_POST['find_us_question'])); // connect to database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $check_query = "SELECT * FROM user WHERE nickname = '$nickname'"; $check_connect = mysqli_query($dbc, $check_query) or die(mysqli_error($dbc)); $check_count = mysqli_num_rows($check_connect); // Check if the email exists twice $query_get = "SELECT email FROM user WHERE email = '$user_email'"; $query_run = mysqli_query($dbc, $query_get); $num_rows = mysqli_num_rows($query_run); // check if username is already taken if ($check_count != 0) { echo "Username already exists!"; } elseif ($num_rows != 0) { echo "This email address is already registered in the database, you can not register it twice."; // check if fields are empty } elseif (empty($user_email) || empty($nickname) || empty($password) || empty($day) || empty($month) || empty($year)) { echo "Please fill out all the fields!"; // check char length of input data } elseif (strlen($nickname) > 30 || strlen($user_email) > 50) { echo "Maximum allowed character length for nickname/firstname/lastname are 30 characters!"; // check password char length } elseif (strlen($password) > 25 || strlen($password) < 6) { echo "Your password must be between 6 and 25 characters!"; // check if passwords match with each other } elseif ($password != $repassword) { echo "Please make sure your passwords are matching!"; } else { // encrypt password $password = sha1($password); I would like to implement now an error message stating something along the lines that the entered email address is not valid, how would I have to do the if statement to check the condition?
  7. This question may be a bit philosophical. As of now I am trying to use: filter_var($email_address, FILTER_VALIDATE_EMAIL) Though in my opinion it allows a bit too much. Then again, is it necessary to have a strict email validation, what is your take on this? It does allow: &&&lol@lol.com And also: blub@blub.conyon I do not know if there are email services which even allow an email like the first one, and I also found out that the validation also does not check for the extension of the email, then again, how necessary is it, and how good can you check for it? What are your suggestions on this one?
  8. Validating an email is that easy nowadays? Did I understand right, all I have to do is: filter_var($email, FILTER_VALIDATE_EMAIL); Is this accurate, the way how I have understood it? How can I tell, what FILTER_VALIDATE_EMAIL finally is doing or how exactly it is filtering, does documentation state this somewhere?
  9. With which programming language, can I analyze the audio to its distortion levels and the volume progress, meaning how the volume is progressing throughout the audio file and also how long the audio file is. I do want to use these analysis procedures as an audio file upload validation mechanism. In this sense, my question is, with which language can I achieve this on the web?
  10. Where in the PHP manual can I find information about input validation? I looked and I seem to not find it. I am intending to create my own email input validation.
  11. I am a new comer myself. But from what I can see, try to rewrite it like this: $dbh = mysql_connect("localhost","XXXXXX_dtbusre","my database password here", "databasename_zxq_dtb" ); $sql = "SELECT loggedin FROM entityTable WHERE username = '{$username}'"; $result = mysql_query($dbh, $sql) or die(mysql_error());
  12. Which XML sitemap generator would you recommend?
  13. The concept may not be there, yet pre-written script can be still used as such as shown sites like codecanyon.net, which does not have a plugin like one I am looking for.
  14. PHP also has a wordwrap function, you know. Thanks a lot, I got it to work.
  15. This is the CSS of a table. The table holds text data which is an user contribution. table.character_artwork_table { clear: both; border: 1px solid #e2e2e2; min-width: 600px; max-width: 750px; empty-cells: show; margin: 2em 0 2em 0em; } table.character_artwork_table td { border: 1px dashed lightgrey; padding: 0 0 0 0.2em; } /* Contribution Area */ table.character_artwork_table tr:last-child > td { padding: 2em 0 2em 2em; font-family: verdana; font-size: 12pt; letter-spacing: 0; line-height: 1; } /* Description Area */ table.character_artwork_table tr:nth-last-child(3) p { padding: 1em 0 1em 0; word-wrap: break-word; } table.character_artwork_table tr:first-child, table.character_artwork_table tr:nth-child(2), table.character_artwork_table tr:nth-child(3) { background-color: #f9f9f9; } table.character_artwork_table tr:nth-last-child(2) { background-color: #f9f9f9; } table.character_artwork_table tr td:first-child img { margin: 5px -20px -40px 5px; } I think I did use the word-wrap in the right way, though I seem to have not, otherwise it would work. Let me explain, the table itself has a maximum width of 750px as you can see in the first block at the top, I am using the word warp property in the description area of the table, and when an entry like for example a continuous string has been done, which breaks the boundaries of the table and stretches the table further than the maximum width than I would like to have the continuous string to be broken BY the maximum width. I also used the break-word attribute, which is supposed to break words which are normally unbreakable. So far, so good, so far I tried to use this property the way I understood it from the description on W3C here: http://www.w3schools.com/cssref/css3_pr_word-wrap.asp Though why does now a continuous string entry like "blaaaaaaaaaaaaaaaaaaaa" not get broken, for me, in my script? And that exactly describes my question. Even though I used everything the way I understood from the documentation this long word still does not get broken. Any suggestions?
  16. The table in the script has a set max-width. How can now a too long continuous text string as in "blaaaaaaaa", which also does not contain a space or dash, be broken, so the table does not become stretched to far? Which function is used for this?
  17. Excuse the beginner question. Though, how do you avoid the processing of HTML when text becomes inputted, without stripping away the tags, or trimming the text in any way, simply leaving it as is?
  18. Is there a tagging or labeling plugin (I like to call labeling) for PHP? I mean those labeling system which you to sort, the user inputs a label, and that label gets assigned to the contribution for sorting system. I am simply looking for one already made which I simply can implement into my own application instead of going through the hassle of creating one myself.
  19. You have sharp eyes. Thank you a lot.
  20. This is the form: <form id="submit_form" method="post" action=""> <label for="knuffix_category"><h4>Choose a category</h4></label><br /> <?php require_once ($sort_category_func); $switch = 0; sort_category ($switch); ?> <br /><br /> <label for="contribution_description"><h4>Enter your description here</h4></label><br /> <textarea maxlength="150" type="text" name="contribution_description" value=""></textarea><br /> <label for="contribution"><h4>Enter your contribution here</h4></label><br /> <textarea maxlength="300" type="text" name="contribution" value=""></textarea><br /> <input type="submit" name="submit" value="Contribute" /> </form> <?php include($submit_script); ?> And this is the script: <?php if (isset($_POST['submit'])){ if (isset($user_name)) { // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Grab the score data from the POST //$knuffix_name = strip_tags(trim($_POST['knuffix_name'])); $contribution_name = uniqid(); if (!empty($_POST['contribution_description'])) $contribution_description = $_POST['contribution_description']; // if (!empty($_POST['knuffix_contribution'])) $contribution = $_POST['contribution']; // if (!empty($_POST['cat'])) { $contribution_category = strip_tags(trim($_POST['cat'])); // } // Check if the fields and variables are empty if (!empty($contribution_category) && !empty($contribution)) { // Check if the submission exists twice in the whole database $query_get = "SELECT contribution FROM con WHERE = '{$contribution}'"; $query_run = mysqli_query($dbc, $query_get); $num_rows = mysqli_num_rows($query_run); if ($num_rows == 0) { // Write the data into the database $query = sprintf("INSERT INTO con (user_id, name, contribution, category, contribution_date, description) VALUES ('$user_id', '%s', '%s', '%s', now(), '%s')", mysqli_real_escape_string($dbc, $contribution_name), mysqli_real_escape_string($dbc, $contribution), mysqli_real_escape_string($dbc, $contribution_category), mysqli_real_escape_string($dbc, $contribution_description)); mysqli_query($dbc, $query) or die (mysqli_error($dbc)); mysqli_close($dbc); /* Set a cookie (later) to prevent duplicate submissions */ // redirect the page to prevent duplicate submissions // header ('Location: redirect.php'); echo 'Contributing was successful.'; } else { echo "This contribution already exists in the database. To keep this place clean we do not allow duplicate submissions."; } } else { echo "Please enter all of the information to add your contribution."; } } else { echo "You have to be signed-in to do a contribution."; } } ?> And this is the error message: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\php_projects\myproject\controller\contribution\submit_script.php on line 38 As the error message states it is not becoming a result, and I do not see where the problem lies, everything looks right to me. Does somebody else see a mistake in there?
  21. In the W3C examples they use a paragraph tag for a line of text as well, and there is also no alternative.
  22. <?php include('../../header.php'); ?> <from method="post" action=""> <input type="checkbox" name="confirmation" value="yes" /> I do confirm to get my password reseted.<br /> <input type="submit" name="submit_confirmation" value="Confirm" /> </from> <?php if (isset($_POST['submit_confirmation'])) $submit_confirmation = $_POST['submit_confirmation']; if (isset($_POST['confirmation'])) { $confirmation_checkbox = $_POST['confirmation']; } if (isset($submit_confirmation)) { echo "works"; } // Check if the user has confirmed the resetting. if (isset($submit_confirmation) && isset($confirmation_checkbox) && $confirmation_checkbox == 'yes') { This is a password resetting script, this script in example occurs after confirmation to have the password reset, the problem I am experiencing is that the script does not get executed and seems that the submit button does not even work to execute the script. I tried to test the submit button by printing out a message stating "works" when pressing the submit button, but that one does not work either. The execution of the whole script does not go path the conditional if statement check in the bottom area, and the statement "works" does not become printed out. Any ideas what is going on here? Here is the whole php file: <?php include('../../header.php'); ?> <from method="post" action=""> <input type="checkbox" name="confirmation" value="yes" /> I do confirm to get my password reseted.<br /> <input type="submit" name="submit_confirmation" value="Confirm" /> </from> <?php if (isset($_POST['submit_confirmation'])) $submit_confirmation = $_POST['submit_confirmation']; if (isset($_POST['confirmation'])) { $confirmation_checkbox = $_POST['confirmation']; } if (isset($submit_confirmation)) { echo "works"; } // Check if the user has confirmed the resetting. if (isset($submit_confirmation) && isset($confirmation_checkbox) && $confirmation_checkbox == 'yes') { // Reset the password of the user $random_password = random(111111, 999999); $query_get = "UPDATE user SET password = '$random_password' WHERE user_id = '{$_GET['id']}' and random = '{$_GET['code']}'"; $query_run = mysqli_query($dbc, $query_get); // Get the email address and user name of the user $query_get = "SELECT nickname, email FROM user WHERE user_id = '{$_GET['id']}'"; $query_run = mysqli_query($dbc, $query_get); $assoc = mysqli_fetch_assoc($query_run); $to = $assoc['email']; $subject = "Your Reseted Password"; $sender = 'From: rochoven@googlemail.com'; $body = ' Hello' .$assoc['nickname']. ', \n\n you requested and confirmed to have your password reseted, here is your new password, please use it to log in and change it to your desired password. \n\n New Reseted Password:' .$random_password. '\n\n Greetings! '; mail($to, $subject, $body, $sender); mysqli_close($dbc); header('Location:'.$password_reset_success); } ?> <?php include('../../footer.php'); ?>
  23. Though I assume that a paragraph tag is not the right use since a line of text is not a paragraph, the use of em solely may be the proper way for this 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.