Jump to content

mrMarcus

Members
  • Posts

    1,903
  • Joined

  • Last visited

  • Days Won

    3

mrMarcus last won the day on December 14 2012

mrMarcus had the most liked content!

About mrMarcus

  • Birthday 06/20/1980

Profile Information

  • Gender
    Male
  • Location
    Canada

mrMarcus's Achievements

Member

Member (2/5)

15

Reputation

  1. mail($email_for_admin, "new member", "{$firstname} {$lastname} has just registered.", "From: \"server.com\" <auto-reply@$host>\r\nX-Mailer: PHP/" . phpversion());
  2. Had a typo in my test code.
  3. To clarify, these are alternatives to CAPTCHA.
  4. This will always return true, regardless of whether $family contains a value or not. The ! operator is checking if !$family is NOT TRUE (Layman's terms: FALSE)... which it isn't. It's also not TRUE. It's not of boolean type. Use empty() when checking form posted values (isset is not necessary since every $_POST'ed form input is sent on form submission. Because of that, you need not check whether they are set; simply check their value's). if (isset($_POST['submit'])) { $foo = $_POST['bar']; if (!$foo) { die('I will always return...'); } } ... <form action="" method="post"> <input type="text" name="bar" value="Go Leafs, Go."/> <input type="submit" name="submit"/> </form>
  5. I made some notes in another thread regarding an alternative to CAPTCHA: http://forums.phpfreaks.com/topic/235697-contact-form-with-math-captcha/?do=findComment&comment=1397557 If OP is interested.
  6. Don't use trim(). Just do this: $md5password = md5($_POST['resetpassword']); EDIT: and remove the following: $_POST = mysql_real_escape_array($_POST); $_POST = trim_array($_POST); You should never trim() or escape a value that is a password. Since mysql_real_escape_array() is not a built-in PHP function, I'm assuming you have created it to map 'mysql_real_escape_string' to the $_POST array, correct? Don't do that. If a user enters a single and/or double quote in their password (their right to do so), mysql_real_escape_string() will escape it and change the hash. Even though you can simply apply this same methodology to future login/registration/password reset applications, it serves no purpose and should be omitted.
  7. I'm also lost. Please talk variable/column names and not "row" and such as your usage is incorrect and hard to follow. The "if" statement is not checking if FamilyID is empty. It is checking for the number of returned records from the query, if any. Your issue would be better straightened out through conditions before executing the query. When you initially login your users, you should then also check for that `FamilyID` value and store it within a $_SESSION variable, just as you (I'm assuming) do with the user ID/name/etc. That way, you can run some conditions before firing the query to check if FamilyID contains a value for that user, and deal with that accordingly.
  8. I was just giving you an example. A best-case scenario, IMO, is a combo of javascript and PHP. The javascript/jQuery for instant notice that there are errors on the form, and the PHP (backend support) for those who have javascript disabled or have malicious intentions. For the PHP, since we are in the PHP forum, can be something as simple as: <?php if (isset($_POST['submit'])) { $errors = array(); if (empty($_POST['q1'])) { $errors['q1'] = 'Please enter a response to question 1.'; } if (empty($_POST['q2'])) { $errors['q2'] = 'Please enter a response to question 2.'; } if (empty($_POST['q3'])) { $errors['q3'] = 'Please enter a response to question 3.'; } if (empty($errors)) { $qone = $_POST['q1']; $qtwo = $_POST['q2']; $qthree = $_POST['q3']; if ($qone == "q1a"){ echo "Your answer to question 1 is: I am pro-life. This is a republican/conservative view.<br />"; } elseif ($qone == "q1b"){ echo "Your answer to question 1 is: I am pro-choice. This is a democrat/liberal view.<br />"; } if($qtwo == "q2a"){ echo "Your answer to question 2 is: I support gun rights. This is a republican/conservative view.<br />"; } elseif ($qtwo == "q2b"){ echo "Your answer to question 2 is: I believe citizens should be unarmed. This is a democrat/liberal view.<br />"; } if ($qthree == "q3a"){ echo "Your answer to question 3 is: I support free markets. This is a republican/conservative view.<br />"; } elseif ($qthree == "q3b"){ echo "Your answer to question 3 is: I support regulating to any extent necessary. This is a democrat/liberal view.<br />"; } } } if (!empty($errors)) { echo 'There are errors in your form. Please see below:<br/><br/>'; $i = 1; foreach ($errors as $error) { echo "{$i}. $error<br/>"; $i++; } } ?> <style type="text/css"> .error { color:red; display:block; } </style> <form name="questions" action="" method="post"> <h4>1. Are you pro-life (against abortion) or pro-choice (for abortion)?</h4> <?php echo (!empty($errors['q1']) ? '<div class="error">'. $errors['q1'] .'</div>' : ''); ?> <input type="radio" name="q1" value="q1a"<?php echo (($_POST['q1'] == 'q1a') ? ' selected="selected"' : ''); ?>/> : I am pro-life<br /> <input type="radio" name="q1" value="q1b"<?php echo (($_POST['q1'] == 'q1b') ? ' selected="selected"' : ''); ?>/> : I am pro-choice <h4>2. Do you believe that gun rights are necessary to preserve safety, freedom and to protect us from tyranny, or do you believe unarmed citizens are safer citizens?</h4> <?php echo (!empty($errors['q2']) ? '<div class="error">'. $errors['q2'] .'</div>' : ''); ?> <input type="radio" name="q2" value="q2a"<?php echo (($_POST['q2'] == 'q2a') ? ' selected="selected"' : ''); ?>/> : I support gun rights<br /> <input type="radio" name="q2" value="q2b"<?php echo (($_POST['q2'] == 'q2b') ? ' selected="selected"' : ''); ?>/> : I believe citizens should be unarmed <h4>3. Do you believe in free markets (limited regulation on business) or do you believe the government should regulate business' to any extent necessary?</h4> <?php echo (!empty($errors['q3']) ? '<div class="error">'. $errors['q3'] .'</div>' : ''); ?> <input type="radio" name="q3" value="q3a"<?php echo (($_POST['q3'] == 'q3a') ? ' selected="selected"' : ''); ?>/> : I support free markets<br /> <input type="radio" name="q3" value="q3b"<?php echo (($_POST['q3'] == 'q3b') ? ' selected="selected"' : ''); ?>/> : I support regulating to any extent necessary<br /> <br /> <input type="submit" value="Tell me if I'm a Republican or Democrat!" name="submit" /> </form> Offered two examples (can be used in conjunction with each other, or separately). You can fart around with the styling, positioning, etc. As well as adding any additional conditions within your form processing code. EDIT: Replace selected="selected" with checked="checked" <form name="questions" action="" method="post"> <h4>1. Are you pro-life (against abortion) or pro-choice (for abortion)?</h4> <?php echo (!empty($errors['q1']) ? '<div class="error">'. $errors['q1'] .'</div>' : ''); ?> <input type="radio" name="q1" value="q1a"<?php echo (($_POST['q1'] == 'q1a') ? ' checked="checked"' : ''); ?>/> : I am pro-life<br /> <input type="radio" name="q1" value="q1b"<?php echo (($_POST['q1'] == 'q1b') ? ' checked="checked"' : ''); ?>/> : I am pro-choice <h4>2. Do you believe that gun rights are necessary to preserve safety, freedom and to protect us from tyranny, or do you believe unarmed citizens are safer citizens?</h4> <?php echo (!empty($errors['q2']) ? '<div class="error">'. $errors['q2'] .'</div>' : ''); ?> <input type="radio" name="q2" value="q2a"<?php echo (($_POST['q2'] == 'q2a') ? ' checked="checked"' : ''); ?>/> : I support gun rights<br /> <input type="radio" name="q2" value="q2b"<?php echo (($_POST['q2'] == 'q2b') ? ' checked="checked"' : ''); ?>/> : I believe citizens should be unarmed <h4>3. Do you believe in free markets (limited regulation on business) or do you believe the government should regulate business' to any extent necessary?</h4> <?php echo (!empty($errors['q3']) ? '<div class="error">'. $errors['q3'] .'</div>' : ''); ?> <input type="radio" name="q3" value="q3a"<?php echo (($_POST['q3'] == 'q3a') ? ' checked="checked"' : ''); ?>/> : I support free markets<br /> <input type="radio" name="q3" value="q3b"<?php echo (($_POST['q3'] == 'q3b') ? ' checked="checked"' : ''); ?>/> : I support regulating to any extent necessary<br /> <br /> <input type="submit" value="Tell me if I'm a Republican or Democrat!" name="submit" /> </form>
  9. The required attribute is not respected by all browsers, ie. IE <=9, for example. I believe it falls within HTML5 capable browsers, so don't rely on it.
  10. In the code you provided, you are not creating a random password. You are simply hashing the string 'resetpassword'. $newpassword = md5('resetpassword'); There is nothing random about that. Nor is that remotely close to how you would handle a form field. If you are using a password from a form field (<input type="text" name="resetpassword"/>) you will need to update your code to accommodate that. You know how to collect field values from a form using $_POST, correct?
  11. Why are you hashing 'resetpassword'? Now, anybody who wants to reset their password is going to be given an identical password to the next. $newpassword = md5('resetpassword'); The issue with your query is you are missing single-quotes around $newpassword. $sql = "UPDATE users SET password = '". $newpassword ."'"; $result = mysql_query($sql) or die("An error occurred ".mysql_error());
  12. from tbcotizacionencabezado join tbmaquinapredet // JOIN on what? inner join tbclientes on tbcotizacionencabezado.idcliente = tbclientes.id inner join tbpersonal on tbpersonal.id = tbcotizacionencabezado.idcreado
  13. No, not in the browser. Copied his array over to Notepad++ and was able to see it. I'm on Chrome also.
  14. Just noticed that. I didn't see it myself until I pasted his array to my editor.
  15. There is a funny character prepended to player: http://s9.postimage....t9tb/Image1.jpg
×
×
  • 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.