Jump to content

per1os

New Members
  • Posts

    3,095
  • Joined

  • Last visited

Everything posted by per1os

  1. Just like any normal insert statement, just make sure the column type is big enough to house it like TEXT or LONGTEXT etc. INSERT INTO my_table (`id`, `html`) VALUES (1, '<html><head></head><body><p>test<br />another test<script>alert(\'a third test\');</script><br />and a final <a href="http://www.phpfreaks.com">PHPFreakS</a><br /></body></html>'); No problem with that at all.
  2. I don't think it was. That is pulling the literal value at index '9' not the actual index of 9 as 9 and '9' are 2 different items. if ( $row[9] == 1 ) { echo "<td>".$img."</td>"; } else { echo "<td>Image Not Available.</td>"; } Is what you want if you are using the actual index of the 0,1,2,3,4...etc If he wanted to call the f15 column this would also work. if ( $row['f15'] == 1 ) { echo "<td>".$img."</td>"; } else { echo "<td>Image Not Available.</td>"; } As long as the array is associative, that is the literal index.
  3. On that note, why not create a function in the class that checks the errormsg variable for you something like: <?php if (!$db->errorEmpty()) { } // (note this should be in the class with the right values function errorEmpty() { if (!empty($this->error)) { return true; } return false; } ?> Should work just the same as you intended it, just a little bit less code and less chance for error as you do not have to add !empty() to ever if statement like this it is simply if !$db->errorEmpty() =)
  4. It seems like the directory is not right, where is the php.ini file located and what is the value for the extension_dir setting in the php.ini file ??? Usually the extensions directory is /extensions not ./ the ./ would be assuming that the extensions directory houses a folder which houses the main php files. That is probably ont the case.
  5. <?php $resultMissing = mysql_query("SELECT id, name, lname FROM `test1`", $db); while ($all = mysql_fetch_array($resultMissing)) { $content .= array_values($all); // note .= } $to = "[email protected]"; $subject = "missing resumes"; $message = "You are missing the resumes on the following profiles, Please control the file name and location or take necessary actions.\n $content \n"; $from = "[email protected]"; $headers = "From: $from"; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?> Give that a try. You were not fetching all the data from MySQL, which is why you would only get one result. Now you are and $content is being appended to house the data.
  6. This forum for example, is a good example of what it takes. It usually takes a solid stream of a good user base, like at least 10,000 unique hits a day, plus at least half of those hits inputting something into the database. Each day for a long time. It takes a bit to reach that point, not really anything to be concerned with unless someone who gets that much traffic + in a day asks you to code for them. But it does take a lot, there are functions out there and tricks you can do to "repair" tables. Never had to use them so I never have.
  7. I dunno man, you have all the information to fix it just in this thread alone. You can catch a fish for a man and feed him for one day, or you can teach a man how-to fish and feed him for life. It just takes a little bit of logical thinking.
  8. [quote=php.net] Using this option, PHP prints out the built in (and loaded) PHP and Zend modules: $ php -m Type that in and post the output here to make sure mysql is installed correctly.
  9. <?php $id = $_POST['id']; $email = $_POST['email']; $first = $_POST['nameFirst']; $last = $_POST['nameLast']; $username = $_POST['username']; $password = $_POST['password']; $md5pass = md5(trim($password)); // see here $cpassword = $_POST['cpassword']; $age = $_POST['age'] ; $gender = $_POST['gender'] ; $ip=$_SERVER['REMOTE_ADDR']; $sqlcheck="SELECT username FROM users WHERE username='$username'"; if ($first == "") { echo "<strong>Error:</strong><br> You havent entered your first name<br/><br/>"; } elseif ($last == "") { echo "<strong>Error:</strong><br> You havent entered your last name<br/><br/>"; } elseif ($username == "") { echo "<strong>Error:</strong><br> You havent entered your username<br/><br/>"; } elseif (strpos($username, $sqlcheck) === FALSE) { echo "<strong>Error:</strong><br> The requested username is in use<br/><br/>"; } elseif ($password == "") { echo "<strong>Error:</strong><br> You havent entered your password<br/><br/>"; } elseif (strpos($cpassword, $password) === FALSE) { echo "<strong>Error:</strong><br> You havent confirmed your password properly<br/><br/>"; } elseif ($email == "" || strpos($email, "@") === FALSE || strpos($email, ".") === FALSE) { echo "<strong>Error:</strong><br> You havent entered your email<br/><br/>"; } elseif ($age == "" || $age < 13) { echo "<strong>Error:</strong><br> You must be 13 or over to join<br/><br/>"; } elseif ($age == "Age (e.g. 14)" || $age == "") { echo "<strong>Error:</strong><br> You havent entered your age<br/><br/>"; } else { include ('includes/mysql_connect_users.php'); // also note the change to the statement below $mysqlinsert="INSERT INTO users(id, username, password, email, firstname, lastname, age, gender, ip)VALUES('$id', '$username', '$md5pass', '$email', '$first', '$last', '$age', '$gender', '$ip')"; $result2=mysql_query($mysqlinsert); if($result2){ echo "<u><strong>Your Login Information</strong></u><br/><br/>"; echo "Your Registered Username Is: ".$username."<br/><br/>"; echo "Your Registered Password Is: ".$password."<br/><br/>"; echo "<u><strong>Other Information</strong></u><br/><br/>"; echo "Your Registered Email Is: ".$email."<br/><br/>"; echo "Your Registered Age Is: ".$age." Years Of Age<br/><br/>"; echo "You Are Successfully Registered, Click <a href='index.php'>Here</a><br/>"; echo " To Go To The Homepage"; echo "<div class='important'><strong><u>Write This Information Down</u></strong></div>"; } } ?> That will fix the user registration portion, you still need to fix the current data.
  10. try using www.php.net/ini_set to set the post_max_size to be like 4 MB's and that should take care of it. Hopefully your server allows the ini_set directive.
  11. When the user registers make sure that password gets hashed, if you just did an insert statement on your own than run this via phpMyAdmin UPDATE users SET `password` = MD5(`password`); Should take care of all user passwords to be md5 hashed.
  12. Alright man, let's try and think here ok? The password in the database does it look something like this: 3ecodr493j39r9jr93j9j39w (MD5 Hashed) Or like this: jackthedog If the password that is IN the DATABASE looks like jackthedog, than it is not MD5 hashed and you are essentially checking 3ecodr493j39r9jr93j9j39w against jackthedog which they obviously do not match. So if the password in the database is not md5 hashed, and it appears like a real word. Than you do not need to md5($password) in the check as it will not work. For security it is best to store the password in the database as MD5 and not the actual word. At any rate, think for a second and check that out, chances are the password in the database looks like "jackthedog".
  13. wow... $sql_user_check = "SELECT * FROM users WHERE username='$username'"; // any literal values need to have single quotes around them. $result_name_check = mysql_query($sql_user_check) OR DIE(mysql_error()); // gives an error message if the sql is invalid
  14. A few tips from someone else's mistakes. 1. Code for international and multi language using UTF-8 it will save you hassle later on. 2. Sanitize input correctly. <?php /* Usage: $data = $_POST['data']; Reqs: Requires mysql_connect to be initiated before use. */ function real_escape($string) { return get_magic_quotes_gpc()?mysql_real_escape_string(stripslashes($string)):mysql_real_escape_string($string); } ?> 3. Security is vital, it sucks to have everything coded and than have to go back and make "corrections" because you did not choose to code for security first. You can always manipulate the functions and make them just return true for development reasons. Anyhow for the time period, it should be an easy task. Just keep the above in mind.
  15. You need a semicolon after include('includes/mysql_connect_users.php')
  16. <br /><option value = '17'>17</option><br /> I do know that the code there should be: <option value='17'>17</option> without the spaces/br's. HTML can be sensitive to spaces after a variable name. <div id='header'>Enter player results for <?php echo fdate($gamedate)?></div><br /><br /> <?php $result = mysql_query("SELECT id, name, team FROM players WHERE team in ('$visitor','$home') AND year='$year' ORDER BY team, name"); $count = mysql_num_rows($result); $teamck = ""; $i = 1; echo "<form method='post' action=''>"; echo "<table>"; echo "<tr><td colspan='14'><input type='hidden' name='count' value='" . $count . "'>"; echo "<input type='hidden' name='date' value='" . $gamedate . "'></td></tr>"; while ($myrow = mysql_fetch_assoc($result)) { $id = $myrow["id"]; $team = $myrow["team"]; if ($teamck != $team) { echo "<tr><td colspan='14' align='center'>$team</td></tr> <tr> <td>Name</td> <td>Order</td> <td>POS</td> <td>AB</td> <td>R</td> <td>1B</td> <td>2B</td> <td>3B</td> <td>HR</td> <td>RBI</td> <td>SF</td> <td>BB</td> <td>K</td> <td>E</td> </tr>"; } if ($count > 0) { $name = $myrow["name"]; echo '<tr><td colspan="14"><input type="hidden" name="id-' . $i . '" value="' . $id . '" />'; echo '<input type="hidden" name="name-' . $i . '" value="' . $name . '" />'; echo '<input type="hidden" name="team-' . $i . '" value="' . $team . '" />'; echo '<input type="hidden" name="gameid-' . $i . '" value="' . $gameid . '" /></td></tr>'; echo "<tr><td>$name</td>"; echo '<td><select name="battingorder-' . $i . '">'; echo "<option value='' selected></option>"; for ($n = 1; $n <= 17; $n++){ echo "<option value='$n'>$n</option>"; } echo "</select></td>"; foreach ($cols as $col) { echo '<td><input type="text" name="' . $col . '-' . $i . '" align="top" maxlength="2" size="2" /></td>'; } echo "</tr>"; $i++; $teamck = $team; } } echo "<tr><td colspan='14'><input type='submit' name='submit' value='Submit'></td></tr><br /><br />"; echo "</table></form>"; ?> Try it like I just posted with the option tag fixed. I do not know why you had <br /> in there, but it was not necessary and could of been screwing it up also. The only other thing I could think of that is happening is there is too much data being passed back to the php script, which may be the issue. Unsure. Anyhow give that a try and see what happens.
  17. Would you mind posting the full output of the html form?
  18. Can you paste the actual form, not the php code to generate the form, but the form code with the 6th column generated?
  19. Than you are going about it wrong. HTML takes the [] as an array. That could very well be why your form is not working. Try something like this: <div id='header'>Enter player results for <?php echo fdate($gamedate)?></div><br /><br /> <?php $result = mysql_query("SELECT id, name, team FROM players WHERE team in ('$visitor','$home') AND year='$year' ORDER BY team, name"); $count = mysql_num_rows($result); $teamck = ""; $i = 1; echo "<form method='post' action=''>"; echo "<table>"; echo "<tr><td colspan='14'><input type='hidden' name='count' value='" . $count . "'>"; echo "<input type='hidden' name='date' value='" . $gamedate . "'></td></tr>"; while ($myrow = mysql_fetch_assoc($result)) { $id = $myrow["id"]; $team = $myrow["team"]; if ($teamck != $team) { echo "<tr><td colspan='14' align='center'>$team</td></tr> <tr> <td>Name</td> <td>Order</td> <td>POS</td> <td>AB</td> <td>R</td> <td>1B</td> <td>2B</td> <td>3B</td> <td>HR</td> <td>RBI</td> <td>SF</td> <td>BB</td> <td>K</td> <td>E</td> </tr>"; } if ($count > 0) { $name = $myrow["name"]; echo '<tr><td colspan="14"><input type="hidden" name="id-' . $i . '" value="' . $id . '" />'; echo '<input type="hidden" name="name-' . $i . '" value="' . $name . '" />'; echo '<input type="hidden" name="team-' . $i . '" value="' . $team . '" />'; echo '<input type="hidden" name="gameid-' . $i . '" value="' . $gameid . '" /></td></tr>'; echo "<tr><td>$name</td>"; echo '<td><select name="battingorder-' . $i . '">'; echo "<option value='' selected></option><br />"; for ($n = 1; $n <= 17; $n++){ echo "<option value = '$n'>$n</option><br />"; } echo "</select></td>"; foreach ($cols as $col) { echo '<td><input type="text" name="' . $col . '-' . $i . '" align="top" maxlength="2" size="2" /></td>'; } echo "</tr>"; $i++; $teamck = $team; } } echo "<tr><td colspan='14'><input type='submit' name='submit' value='Submit'></td></tr><br /><br />"; echo "</table></form>"; ?> Unsure if that will suit your needs, but yea the [] is definitely not right as HTML takes that as an array submission. As long as it starts at one and just increments you should be able to extract that data by doing something like this: <?php $i=1; while (isset($_POST['id-' . $i])) { $ids[] = $_POST['id-' . $i]; // .. etc for the rest of the fields $i++; } ?>
  20. Yes, I know I rock. You can create a table of words, but is unnecessary as all you would needs is one row with a LONGTEXT column type, and just house all the words there comma separated. Would probably run faster than pulling each word separately, whichever you want to go is your choice just as long as each individual word is an array. I do not call the word file inside the function due to that if you use it 2 or 3 times you are already less efficient, having them read into memory first and than running it 2 or 3 times is a lot more efficient. #2, see code below: <?php $words = "cialis,viagra, levitor"; $wordList = explode(",", $words); if (is_spam($_POST['comments'], $wordList)) { //header('location: bootspammer.html'); // Note the header code inside the if.. echo $test . " has been flagged as spam<br />"; echo "To boot them out place header code here!!!"; } function is_spam($check, $wordlist) { $check = trim($check); if ($check == "" || empty($check)) { return false; // nothing to check against } if (!is_array($wordlist)) { $wordlist = explode(",", $words); } foreach ($wordlist as $word) { $word = trim($word); // for good measure if (eregi($word, $check)) { return true; // this is spam } } return false; // must not be spam } ?> #3: It is not wise to explode it into it's own words as that would be less efficient and unnecessary as you would be running 2 loops when only 1 loop is required. As you can see this function works great with the string as a whole, no need to explode it at all, especially since user input can vary so much that anyone could easily defeat that if you use the explode feature. Hope that helps.
  21. Ummm yea, what I suggested earlier, try removing the $i out as it is not necessary. <?php echo '<td><input type="text" name="pos[]" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="ab[]" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="r[]" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="b1[]" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="b2[]" align="top" maxlength="2" size="2" /></td>'; echo '<td><input type="text" name="b3[]" align="top" maxlength="2" size="2" /></td>'; ?>
  22. Obviously you were not looking in the right spot. Came straight from the php.net manual off of the preg_replace users comment section. I have not tested, but I am sure it works great.
  23. sighs. That of course would not work, data is converted to an array when the data is posted. <?php $data = $_POST['data']; print_r($data); echo '<br /> OR: ' . $data[0]; ?> Whoever posted that needs to learn how to do stuff the proper way, damn. <?php $PHP_SELF = $_SERVER['PHP_SELF']; $year = 2007; $visitor = isset($_POST['visitor'])?$_POST['visitor']:''; // sets value to '' if the variable is not set. $home = isset($_POST['home'])?$_POST['home']:''; $gameid = isset($_POST['gameid'])?$_POST['gameid']:''; $gamedate = isset($_POST['gamedate'])?$_POST['gamedate']:''; ?> Would be the "proper" way to set variables from post/get data. On that note "notices" are exactly that, just a notice. They would not be the issue why the form data is not submitting. They would not be the cause. As for the action being blank, there is no need you have PHP_SELF defined, use it. That may not be the problem, but certainly is not the ideal way to create a form. <?php echo "<form method='POST' action='" . $PHP_SELF . "'>"; ?> Finally as the last resort setup a unit test, to figure out where it is going wrong. post_test.php <?php if (isset($_POST['submit'])) { echo 'The data posted was:<br />', print_r($_POST), '<br />'; } echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="POST"><input type="hidden" value="Test" name="testing" /> <input type="text" value="This is just a test" size="30" name="MyTest" /><br /> <input type="submit" value="Test me Out!" name="submit" /><br /> </form>'; ?> Run that script on your server and see what happens. If you are getting output than it is an issue with the script somewhere, if you are not than the server is setup to access the $_POST differently. I would suggest trying $HTTP_POST_VARS (although depreciated maybe the host decided to use those instead). EDIT::: After looking at this: <?php foreach ($cols as $col) { echo '<td><input type="text" name="' . $col . '[' . $i .']" align="top" maxlength="2" size="2" /></td>'; } ?> Change it to this and try the form. <?php foreach ($cols as $col) { echo '<td><input type="text" name="' . $col . '[]" align="top" maxlength="2" size="2" /></td>'; } HTML forms probably has a heartache about you trying to define the index in the array. Try it out and see how it goes. EDIT Num2: Here is the full code with the $i portion removed for easy trial: <div id='header'>Enter player results for <?php echo fdate($gamedate)?></div><br /><br /> <?php $result = mysql_query("SELECT id, name, team FROM players WHERE team in ('$visitor','$home') AND year='$year' ORDER BY team, name"); $count = mysql_num_rows($result); $teamck = ""; $i = 1; echo "<form method='post' action=''>"; echo "<table>"; echo "<tr><td colspan='14'><input type='hidden' name='count' value='" . $count . "'>"; echo "<input type='hidden' name='date' value='" . $gamedate . "'></td></tr>"; while ($myrow = mysql_fetch_assoc($result)) { $id = $myrow["id"]; $team = $myrow["team"]; if ($teamck != $team) { echo "<tr><td colspan='14' align='center'>$team</td></tr> <tr> <td>Name</td> <td>Order</td> <td>POS</td> <td>AB</td> <td>R</td> <td>1B</td> <td>2B</td> <td>3B</td> <td>HR</td> <td>RBI</td> <td>SF</td> <td>BB</td> <td>K</td> <td>E</td> </tr>"; } if ($count > 0) { $name = $myrow["name"]; echo '<tr><td colspan="14"><input type="hidden" name="id[]" value="' . $id . '" />'; echo '<input type="hidden" name="name[]" value="' . $name . '" />'; echo '<input type="hidden" name="team[]" value="' . $team . '" />'; echo '<input type="hidden" name="gameid[]" value="' . $gameid . '" /></td></tr>'; echo "<tr><td>$name</td>"; echo '<td><select name="battingorder[]">'; echo "<option value='' selected></option><br />"; for ($n = 1; $n <= 17; $n++){ echo "<option value = '$n'>$n</option><br />"; } echo "</select></td>"; foreach ($cols as $col) { echo '<td><input type="text" name="' . $col . '[]" align="top" maxlength="2" size="2" /></td>'; } echo "</tr>"; $i++; $teamck = $team; } } echo "<tr><td colspan='14'><input type='submit' name='submit' value='Submit'></td></tr><br /><br />"; echo "</table></form>"; ?> In Regards to brethl's post I noticed that brethl did not explicitly state that you need to put that var_dump stuff inside the isset($_POST['submit']) if portion as you were killing the script before you had a chance to enter any data, which is why it returned blank values.
  24. Missing the rejection part...ummm that is the great thing about a function...check this out. <?php $words = "cialis,viagra, levitor"; $wordList = explode(",", $words); $check = "The best part off waking up is having Cialis in your CUP!!"; if (is_spam($test, $wordList)) { //header('location: bootspammer.html'); // Note the header code inside the if.. echo $test . " has been flagged as spam<br />"; echo "To boot them out place header code here!!!"; } function is_spam($check, $wordlist) { if (!is_array($wordlist)) { $wordlist = explode(",", $words); } foreach ($wordlist as $word) { $word = trim($word); // for good measure if (eregi($word, $check)) { return true; // this is spam } } return false; // must not be spam } ?> Either way man, good luck trying to debug that other function, especially when the one presented above does the same thing, except it actually works.
  25. My opinions are educated with many bad experiences due to captcha. Namely, the amount of time it can take if someone implemented it wrong and if you guess the word wrong than you have to fill out forms again. Or they made the image insanely hard to read/see so that it is nearly impossible to get it right in the first 20 tries, hence "lame". It sucks filling out a form two or even three times, it sucks even worse trying to get the image correct and still failing after 20 tries because of how the creator setup the captcha. Captcha does work for the most part, for the most part. But there are other solutions, and there will need to be other solutions too as it was stated, bots get smarter every day and it is just a matter of time before captcha is rendered completely useless. It may be good to pioneer a new way which is less of hassle to the user. I still stand by my original comment, Captcha's are definitely lame.
×
×
  • 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.