
Zephyr_Pure
Members-
Posts
17 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Zephyr_Pure's Achievements

Newbie (1/5)
0
Reputation
-
Mail() returns true even without header information
Zephyr_Pure replied to tyooseph's topic in PHP Coding Help
http://us3.php.net/manual/en/function.mail.php It's an optional argument to the function... as long as the php.ini has a default set. A lot of webhosts have this configured already. -
Ahh, good catch!
-
Mail() returns true even without header information
Zephyr_Pure replied to tyooseph's topic in PHP Coding Help
Put the mail() function inside an if conditional and check to make sure !empty(headers). That should at least help some with your problem. -
1. Two ways: a. Put a "Reset" button by the select (that's not actually a reset input element) and have the onClick() event for that hide all of the forms (effectively resetting to before an option was chosen). b. Do as the other guy said (with a submit and reset button) and make the submit pass the select value in its own form, then display the proper form based upon that value. Make the reset button just a plain button (as in the above option) and display no forms if !empty($_POST['resetbuttonname']). Alternatively, just put a "None" option in the select and, when that gets submitted, display no forms. 2. Anywhere, really. Traditionally, though, I've always seen form processing code at the top of the page, encased in a isset($_POST['whatever']) conditional. That way, you only execute the mail() code when the form is actually submitted.
-
Determining State Of Radio Buttons With PHP
Zephyr_Pure replied to cosmicsafari's topic in PHP Coding Help
In which case he will need to name them differently for each item, or the option chosen in the last will overwrite all of the rest. Radio buttons should be named the same within a single choice, but differently between questions. -
Well, you could "cheat" and use preg_replace with a limit: $string = "blabla<input type='checkbox' value='' name='utakmica'>blaablaablaa<input type='checkbox' value='' name='utakmica'>blaablaablaa<input type='checkbox' value='' name='utakmica'>"; $array = array("b1", "b2", "b3"); $count = count($array); for ($x = 0; $x < $count; $x++) { preg_replace("/value=''/","value='".$array[$x]."'",$string,1); } Probably not the most efficient way, but it should work.
-
Determining State Of Radio Buttons With PHP
Zephyr_Pure replied to cosmicsafari's topic in PHP Coding Help
On-topic: It looks like you'd need to use a checkbox or separate forms for each item, depending on your intent. Radio buttons should be used to capture a single choice (or question) only, not a single choice that references a whole block of other choices (item name, etc.). If you're looking for a multi-select cart, use checkboxes. If you're looking to allow editing or adding or whatever from a list of multiple things, use separate forms. Off-topic: Even though $_REQUEST contains both $_POST and $_GET (and $_COOKIE), it is not a good idea to use it as it can be a security risk. Basically, it exposes all of those superglobals above so that someone could inject values through the URL query string (since a $_GET variable would look no different than a $_POST or $_COOKIE). This could cause unexpected results if you were insufficiently protecting what you thought were "safe" values (which, of course, no inputs are safe). Rule of thumb: - Use $_POST when performing transactions. - Use $_GET mainly when displaying referenced data... or to supplement (but not entirely be) a form request. - Use $_REQUEST only as a shortcut to sanitizing your inputs with the same method. -
You're not checking to see that the result actually contains a result row. Use a conditional statement to test that the $result has num_rows() > 0 before you fetch_assoc() it.
-
Break up your code some... so you can see what you're echo'ing and what you're not. Instead of the above, do this: <?php if ($action == modify) { ?> <!-- HTML HERE --> <?php } ?> ... and for checking the selected part (as an example), do: <option value="No" <?php if($clientview=='No'){echo 'selected'; }?>>No</option>
-
Well, you were asking about hashed passwords and verifying those... and your code does neither as people suggested. For example, if you're storing your passwords as SHA-1 in the database, you could do this: $password = $_POST['$password']; $username = $_POST['$username']; $dbusername = "SELECT uname FROM users WHERE uname = '$username' && upass = '$password'"; $dbpassword= "SELECT upass FROM users WHERE uname = SHA1('$username') && upass = SHA1('$password')"; Technically, you could do that in one query, but I could see how it would be easier to start learning with separate variables. Oh, and here's a good reference on MySQL Encryption functions: http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html Finally, for comparing the user and pass, you got some good advice on using string comparisons... so, put 'em to use! Examples from the advice given earlier in the thread: if ( $username !== $dbusername || !strcmp(sha1($password),$dbpassword) ) { $error .= "Invalid Credentials"; } Just take your time and read through the replies you get a couple times. If they don't make sense right off, just keep at it and give it time... but at least try to research the functions and methods that people are recommending to you so that you can understand how they work and why they're good.
-
Instead of doing a num_rows and a for loop with a second MySQL statement, just do this: $mysql = new mysql(); $result = $mysql->doQueryA('SELECT id,name FROM category'); foreach ($result as $r) { echo $r['name']; // Then, do a second query to pull your subcategories... something like this: $result2 = $mysql->doQueryA('SELECT name FROM subcategorie WHERE categorie_id='.$r['id']); foreach ($result2 as $r2) { echo 'Subcategory: '.$r2['name']; } } Just kinda guessed at the subcategory table, since you didn't really describe the layout of the tables.
-
I'm thinking that there's a server var called "QUERY_STRING" that would hold your GET vars after the ?. Also, taking the basename() of the REQUEST_URI should give you the filename. Maybe you have to pass the query string on to the requested URI by setting it? If all else fails, you could just use cURL to retrieve the page and dump the response in your handler page.
-
Pretty sure you have this one confused with "\n", which is a line break; you can also use chr(13), which is the same thing.
-
... and change the value of the hidden input to ($x + 1) instead of just $x. If that's not what you're looking for, you'll need to provide more info about what the code is actually doing.
-
Unexpected $end at the end of a document usually means that you forgot to close a conditional block with a bracket. There aren't any errors of that sort in that page of code you posted, so do any of those functions you're calling do any includes? Have you checked the includes for missing brackets?