Jump to content

PHP_PhREEEk

Members
  • Posts

    840
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

PHP_PhREEEk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <?php $dbhost = "localhost"; $dbname = "andy"; $dbuser = "root"; $dbpass = "admin"; //Connect to database mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error()); mysql_select_db($dbname) or die(mysql_error()); echo '<pre>'; print_r($_POST); echo '</pre>'; if ( isset($_POST['username']) ) { $username = $_POST['username']; } if ( isset($_POST['password']) ) { $password = md5($_POST['password']); } if (isset($username)) { echo "user var is set."; } if (isset($password)) { echo "pass var is set."; } $query = "select * from users where username='$username' and password='$password'"; $result = mysql_query($query); if (mysql_num_rows($result) != 1) { $error = "Bad Login"; include "loginform.php"; } else { //session_start(); $_SESSION['username'] = "$username"; require_once "index.php"; } PhREEEk ?>
  2. If you don't care about error-checking, sure... If you care about error-checking, you can do it client-side using Javascript or AJAX. The form can only be submitted once it passes all tests. PhREEEk
  3. and no definition of what 'not working' means... PhREEEk
  4. I've seen a few script hacks that use output buffering to do this, but haven't seen one in awhile. I believe, though, that that is what you're looking for. PhREEEk
  5. When I copy text from a web page and paste into Notepad, I get the line breaks just fine... When typing into a textarea, the same behavior exists by where if I copy/paste to Notepad, those line breaks transfer as well. So, you may be thinking too far ahead... = ) Try some experimenting with your form, and if something starts not behaving as expected, post and we'll figure it out! PhREEEk
  6. A function cannot have a $ in front of the name. <?php $trim($value) needs to be <?php trim($value) PhREEEk
  7. If you mean you want PHP to force a file to be downloaded rather than streamed in, try this link: http://www.phpfreaks.com/forums/index.php/topic,95433.0.html PhREEEk
  8. Interesting Barand, something I've always kind of figured, but certainly never tested. To the OP, I do what you are saying quite often, and I consider it an extremely valid way to present your HTML. I also find that it causes me to program in a way that steers me clear of the dreaded "Headers already sent" error. When I am absolutely committed to sending a whole page, I call the functions that do it. Going back to what Barand tested, I don't use the functions in that manner typically. My functions used to send content usually echo that content from within the function, so rather than doing echo html_function();, I just say html_function();. I don't know whether or not that would satisfy an increase in speed slightly over building an entire string with the function's content, then echoing the string. I should test that some time when I'm bored enough. = ) The whole concept here is to try and keep unnecessary PHP out of the HTML. Your PHP should be processed up front, and then like I said, when all conditions are present to be committed to sending the page, send the page! You can't avoid the occasional loop in the middle of your HTML, but you should rarely ever need to make coding decisions while your HTML is being output. Early on in my PHP travels, I grew to absolutely detest code that opens and closes PHP a zillion times. What an absolute nightmare to try and trouble shoot. Without much tutoring to go on (sites like PHP Freaks weren't around back then), I just slowly developed ways around having to do it that way. One of the solutions was to use functions to echo out large chunks of ready-to-go HTML content. I guess the concept here is, don't go crazy with it... it's just one tool, one which I consider valid if used for specific reasons that make sense to YOU. That's the bottomline, isn't it? Because at the end of the day, a small negligible reduction in performance is acceptable to me if I'm 'connected' to the flow of my code. I want to be able to trouble shoot it and modify it as easily as possible while developing. The spirit of PHP is the ease with which each coder can develop a 'style' and be flexible with the architecture. A lot of hard liners would like to see PHP become more strict with architecture, but I'll let them argue... code that works, just works. If a bottleneck develops, find the section of code responsible and fix it. If you believe your application suffers from some performance issues, try echoing from within the function instead of creating a huge string and returning it. PhREEEk
  9. Please check into natsort(), which attempts to sort an array the way a 'human' would attempt to sort it... examples given at the link provided. There are many other sorting options available on the left hand nav of the page. PhREEEk
  10. You can test for data being present, then dumping the data (for testing) if any records do exist: <?php if ( !$result = mysql_query("SELECT * FROM users") ) { die('MySQL Error: ' . mysql_error()); } if ( mysql_num_rows($result) > 0 ) { while ( $row = mysql_fetch_assoc($result) ) { echo "<pre>"; print_r($row); echo"</pre><br>"; } } else { echo "No results from query!"; } PhREEEk
  11. The Form type to hold what you want is a simple enough HTML textarea form. You can define the screen size of it via columns/rows. I'm sure you can google HTML textarea and figure that out... = ) The receiving script that processes the form can convert the new lines to '<br>' automatically using the nl2br() function. PhREEEk
  12. That is indeed a db selection statement, but which one are we going to use? Here you say "username", above you used "login". What's the db name? PhREEEk
  13. You cannot have a function declared within a while loop (or any loop for that matter). Every time the loop iterates, the function will be redeclared to PHP, which will obviously error. Place all functions at the bottom of your script, away from everything else. Call the function inside your loop with <?php while ( some_condition ) { // do stuff formatfilesize( $size ); // more stuff } // end loop // rest of code PhREEEk
  14. Replace <?php $result = mysql_query("SELECT * FROM users"); with <?php if ( !$result = mysql_query("SELECT * FROM users") ) { die('MySQL Error: ' . mysql_error()); } PhREEEk
  15. You would need to adjust your query ($query_notifier, which isn't shown to us) and test for num_rows of multiple appointments. It would be handy to undertsand the schema of your table that holds the appointments. Anyways, if num_rows ends up > 1, you would do a loop to pull all the appts for that client. Easy to do, but we need more information to give you more detailed options. PhREEEk
×
×
  • 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.