";
echo "";
$number_t++;
$number_c++;
$value_c++;
}
?>


*this is kind of a followup from my previous question

Source: http://community.livejournal.com/php/527528.html

  • PHP/MySQL Help

    Date: 01/05/07 (WebDesign)    Keywords: php, mysql, html, database, sql, web

    Hoping somebody here can help me..

    I'm going through the book PHP and MySQL Web Development by Luke Welling and Laura Thompson. I'm currently working through Chapter 26 (for those of you that have read it), Building User Authentication and Personalization. I've gotten through it pretty good so far, but am having some trouble with actually authenticating the user logins. My site is set up at http://test.aacapartsandsupplies.com. My problem is, whenever I click the login button, I always go to the member.php page.. even if I didn't put any login information in. It doesn't throw back any errors saying "you must be logged in to view this page", etc. Even if I do login, and I try to logout from member.php, it throws back the exception "you were not logged in, and so have not been logged out." I have registered some test users, and this happens on every login I've created.

    I'm not exactly sure where the problem lies. I'm wondering if anyone has read this book and might be able to help me out. Even if you haven't read it and know more about PHP/MySQL than I do, I'd appreciate any kind of help. Posting the code for the two files where I *think* the problem lies.


    < ?php

    // include function files for this application
    require_once('tokens_fns.php');
    session_start();

    //create short variable names
    $username = $_POST['username'];
    $passwd = $_POST['passwd'];

    if ($username && $passwd)
    // they have just tried logging in
    {
    try
    {
    login($username, $passwd);
    // if they are in the database register the user id
    $_SESSION['valid_user'] = $username;
    }
    catch(Exception $e)
    {
    // unsuccessful login
    do_html_header('Problem:');
    echo 'You could not be logged in.
    You must be logged in to view this page.';
    do_html_footer();
    exit;
    }
    }

    do_html_header('');

    display_user_menu('');

    check_valid_user('');

    ?>

    < div id="right">
    < div id="title">
    < h1>Welcome to your AACA Locker < ?php $_POST['username'] ?>
    < /div>

    Thanks for logging in! You may now view your custom reports, vote in our
    polls, and be sure to check for any rewards you may have won!


    < /div>

    < ?php

    do_html_footer('');
    ?>



    This is simply the login and check_valid_user functions:

    function login($username, $passwd)
    // check username and password with db
    // if yes, return true
    // else throw exception
    {
    // connect to db
    $conn = db_connect();

    // check if username is unique
    $result = $conn->query("select * from user
    where username='$username'
    and passwd = sha1('$passwd')");
    if (!$result)
    throw new Exception('Could not log you in.');

    if ($result->num_rows>0)
    return true;
    else
    throw new Exception('Could not log you in.');
    }

    function check_valid_user()
    // see if somebody is logged in and notify them if not
    {
    if (isset($_SESSION['valid_user']))
    {
    echo '
    ';
    echo 'Logged in as '.$_SESSION['valid_user'].'.';
    echo '
    ';
    }
    else
    {
    // they are not logged in
    echo '
    ';
    echo 'You are not logged in.
    ';
    exit;
    }
    }


    I can provide more code if needed.

    Thank you all in advance!!

    Source: http://community.livejournal.com/webdesign/1203673.html

    1. Potentially a dumb question...

      Date: 12/03/06 (PHP Community)    Keywords: database, sql

      I feel like I should know how to do this but I am stumped and perhaps it's because I'm sick but anyway...

      I have a form that will be used to search a database. The form has a total of 12 fields which can be filled out to perform the search.

      My question is: Is there an easy way to include or exclude the fields in SQL query when accessing the database? That is, I only want to include the fields where something has been entered in the query string and am not sure how I would go about doing that.

      Any help is greatly appreciated. Thank you in advance!

      Source: http://community.livejournal.com/php/516175.html

    2. Sharepoint server

      Date: 12/04/06 (IT Professionals)    Keywords: database, sql

      I am trying to determine an easy way to backup a MS SharePoint Server. I am trying to do this on the cheap and have a MSSQL backup utility that is incorporated with my current backup solution.

      Can I do backups of the MSSQL databases and that is all? And then when I have disaster, reinstall the OS, the Sharepoint, MSSQL and then restore the data in the database? Or will I need to use Stsadm.exe utility in conjunction with the above method?

      Does anyone have any familiarity with Sharepoint and backups?

      Source: http://community.livejournal.com/itprofessionals/48486.html

    3. Excel Help?

      Date: 12/05/06 (Microsoft Windows)    Keywords: database

      Hello all.

      First time poster here. I hope someone can help me.

      I am a geneticist looking at epilepsy. I have a large Excel database of the samples that come in My problem is that I want to associate numerical scores to the type of seizure that the patient suffers.

      So I record the seizure type for each sample in column D. There are 8 options for seizure types:

      (generalised, focal, myoclonic, other, multiple - G+F, multiple - G+F, multiple - G+F+M, multiple - F+M).

      In column E I assign a value depending on the seizure type, so generalised is 1, focal is 2 and so on.

      At the moment I'm having to do it manually which is extremely time consuming. Can someone help with a formula or maybe even a macro(?) that would allow automatic entry of a value in column E depending on column D?

      I'm not terribly good at things like this and I've tried using the IF formula but as far as I can tell, it doesn't really like more than 2 possible outcomes.

      Thank you in advance!

      Source: http://community.livejournal.com/ms_windows/73394.html

    4. MySpace to offer technology to block sex offenders

      Date: 12/05/06 (Security)    Keywords: database

      Social network will build feature to search federal, state databases and delete MySpace profiles of registered sex offenders.

      Source: http://news.zdnet.com/2100-1009_22-6140967.html

    5. any geo-targeting recommendations?

      Date: 12/05/06 (Web Development)    Keywords: php, database

      I'm trying to setup a site that redirects users based on which country their IP is from. Do any of you have any recommendations for free databases or scripts (php preferre) that will keep an accurate list of ip to country mappings?

      Source: http://community.livejournal.com/webdev/374616.html

    6. Medical records mashup would span a lifetime

      Date: 12/07/06 (Application Development)    Keywords: database

      Five major companies have joined forces and invested in what appears to be the ultimate personal medical-records database.

      Source: http://news.zdnet.com/2100-9593_22-6141601.html

    7. Guilty by association to spam

      Date: 12/08/06 (PHP Community)    Keywords: php, html, database, web, spam, google

      I've got an interesting problem that's stumped both the senior programmer and me.

      Situation:
      A user is looking for a company to provide a service, they find our site at or near the #1 position on a google search result, they find a company where they need the service done, and they send a request for a quote via a php form. The form processes this request, logs it into the DB, and at a set time, that record is dropped into a MTA. This is the problem.

      `From: $UserProvidedEmailAddress`

      Problem:
      In an ideal world, this would be fine, but thanks to spam... this sets of just about every single spam filter I know of and then a day/week later we are suddenly blacklisted by everyone including our own email service provider. In the last two months we've had to call up the spam database companies and get taken off the list (after a day or week of them doing necessary investigation to find we are in fact not spamming). The next logical step would be to replace the from field with a real email account like `info@ourserver.com` and then put the user provided email address in the `reply-to:` field of the email header instead. But my senior argues that we will still set off the spam filters and I agree and I can't see how to fix this.

      So to review:
      There are 3 parties involved in these script generated emails.
      Customers who provide us their email addresses via the form. We protect the email addresses and flush them after 60 days (legal reasons)
      Advertising clients who pay us to get these emails from our top listed site.
      Ourselves, all transactions are bcc to us so we can track initial user to advertiser interactions and make sure we are providing the product our clients are paying us for( customers and web presence)


      Why:
      My employers want to keep it as simple as possible for our clients to respond to potential customers, hence the customer email address in the from field. But that doesn't work because of spam.


      Thoughts:
      Also, we can't put advertising client email addresses on the site or make them accessible to humans because spam-spiders will get them and proceed to spam the client's.
      My senior has written a working prototype for an in-site messaging system using rails, but the fear is that some of our clients are to lazy/stupid to use it... I agree, some of these people are pretty dumb.
      Another thought would be to put some sort of mailto: url in the emails, but not everyone uses html enabled email clients.

      Source: http://community.livejournal.com/php/518711.html

    8. Getting information from more than one table

      Date: 12/11/06 (MySQL Communtiy)    Keywords: database, web

      [edit to add:] Problem solved - in the end I have merged the tables together so all the data is now in one table. Thank you everyone for your suggestions - it was just getting too complicated and dragging the search time down with the data split out.

      Hi

      I'm working on a project that has 600,000+ records and they have been divided up by state in the database (therefore there are 51 different tables - including DC) and I'm having a problem getting all of the data out of the tables when more than one table is selected.

      My original select statement looks something like this:

      -----

      SELECT AZ_ID,AR_ID,AZ.BusinessName,AR.BusinessName,AZ.Address,AR.Address,AZ.City,AR.City,AZ.State,AR.State,
      AZ.Zip,AR.Zip,AZ.Phone,AR.Phone,AZ.SalesVolume,AR.SalesVolume,AZ.ContactFirstLastTitle,AR.ContactFirstLastTitle
      FROM AZ, AR WHERE AZ.SalesVolume = 'Less than $500,000' AND AZ.WebAddress IS NOT NULL
      AND AR.SalesVolume = 'Less than $500,000' AND AR.WebAddress IS NOT NULL LIMIT 500

      -----

      I have tried doing joins but there are no common fields so it is returning the results of the last state selected.

      Any assistance would be greatly appreciated as this has been stumping me for the past little while.

      Source: http://community.livejournal.com/mysql/107000.html

    9. Identity column vs Unique ID generated in C# assembly

      Date: 12/12/06 (SQL Server)    Keywords: database, sql

      x-posted to '[info]'databases

      As part of our current SQL setup we've got an extended proc that calls a C++ DLL to generate a unique id for all db calls. This unique id is use as a primary key on a logging table that is inserted into (along with user id, destination stored proc and any params) prior to running the users call. Also this unique id is added to the params list and passed on to the destinition stored procedure. Finally the logging table is updated with the return code of the call.


      Unfortunately this DLL won't work under SQL 2005, therefore I'm rewriting as part of the upgrade. That isn't the problem. The problem is one of the DBAs asking why we just don't use an Identity column on the logging table. TBH I couldn't think of a reason why not, especially if we use SCOPE_IDENTITY rather than @@IDENTITY. The only reason I could think of is historical, ie the original developers didn't trust SQL Server to handle the load (the DLL has been used since at least SQL 6). Can you think of situation where the use of an Identity column would fail?

      Source: http://community.livejournal.com/sqlserver/54552.html

    10. Looking for Online Collaboration Tools

      Date: 12/14/06 (Computer Geeks)    Keywords: database, web, google

      I run a photo studio. All artists in residence in the studio are working on the same project this year. We have almost a hundred models in our book, and need to find a way to share a calendar so that we can all put down when we're available, not available, have shoots scheduled, and the like. We also need to have an online database for all of our models where we can all see the models' information, write notes, share images, and the like.

      In short, we need an online collaboration system.

      We've looked at Google Web Apps, and that has nice shared email and a decent calendar, but nothing even close to a shared online database for our models.

      Anyone have any suggestions? Free or pay, either is fine. I'm perfectly cool paying for something that works.

      Source: http://community.livejournal.com/computergeeks/1010676.html

    11. Email validation & quick Rails vs. PHP

      Date: 12/16/06 (PHP Community)    Keywords: php, software, database, web, apache

      Was playing with the idea of regEx'ing out the domain of an email address and then doing a gethostbyname() to verify that the email address is valid. I know in some cases this won't work, but was curious if anyone has ever tried something similar. Just trying to come up with more validation measures to protect my employeer and their customers from malicious users.


      As for Rails VS. PHP

      Rail cons
      I am on the final stage of deploying a website built in rails and it's been a fun/frustrating learning experience because I've had to build it with a legacy schema that was mangled along the same lines as scope creep (non-standard keys, non-uniform structure (integer keys here, varchar keys there, variables inside join tables, and a lot of orphaned tables forcing the client software to do what the database should be doing [out of query joins or excessive join tables]). For the most part there is a lot of good things about Rails but it's not an end all, be all tool like some people make it out to be. Multi-page/multi-object (ex. user data mixed w/ purchase data) forms are difficult, breaking the rails way of data validation. Debugging has some nice benefits, but is poorly documented and so far I have not found a Rails equivalent to DBG symbolic debugging.... the best appears to be a rails inline assert/breakpoint object that halts the entire system to allow you a glimpse of the system state at that moment but not the ability to step in/out/over.
      Lastly there is no mod_perl or mod_php like Apache component so getting Rails on a current server implementation is somewhere between entertaining to unbelievably frustrating. Further more, though rails has a couple different natively supporting webservers (light, webbrick, mongrel) they aren't as well tested or as versatile as Apache. And lastly there is little to no documentation or guidelines, so if you got to do something out of the ordinary, life gets interesting.

      Rails pro's
      On the plus side, Rails is rich in features, its easier to write C binary packages then PHP, the ActiveRecord & ActiveMailer packages are extremely versatile and thanks to standard Obj. Oriented mantra's, base/parent methods can be supplemented or completely overridden. Otherwise it's a great rapid development platform and practically promotes itself to being used in series with another scripting language if Apache 2.0's mod_proxy or similar httpd proxy service is used. `httdoc/{rails sub-dir/ &| php sub-dir/ & /static content dir}` Prototype and Scriptalicious (spelling) being embedded and wrapped by Rails helpers make Ajax/Web 2.0 stuff a breeze as well. So if you got a simple project on queue and the time to burn stumbling through Rails, I'd recommended checking it out to see if it can compliment and augment your portfolio. Just be prepared to earn your paycheck for the first couple projects. So for speed and minor enhancements to static content, PHP dominates while for complicated, Ajax heavy applications, Rails feels like a good choice.

      Source: http://community.livejournal.com/php/522413.html

    12. Finnish mySQL support was 3rd most-read story of 2006 on open source blog

      Date: 12/18/06 (Open Source)    Keywords: mysql, database, sql, web

      Small companies face a Hobson's Choice as they grow. They may start with mySQL, a solid, simple database, but they wonder whether it will scale as they grow. Given the penchant of Web companies to grow exponentially if they turn out to be winners, this is a question that is occuring earlier-and-earlier in these companies' lives.

      Source: http://feeds.feedburner.com/~r/zdnet/open-source/~3/63255940/

    13. IT worker indicted in hacking scheme at health firm

      Date: 12/19/06 (Security)    Keywords: database

      Prosecutors say malicious code, if activated, would have wiped out databases of prescription information, potentially harming patients.

      Source: http://news.zdnet.com/2100-1009_22-6144868.html

    14. Security concerns with User Sessions

      Date: 12/20/06 (PHP Community)    Keywords: mysql, database, sql, security

      As part of a development project, I'm currently developing a site which will require user login to access most of the actual site content. However, I want to ensure that I set this up with the most common security holes taken into account.

      The user data is stored in a MySQL database, with the username stored in cleartext and the password field contains the md5 hash of the actual password concatenated with a 10 character random salt string (which is stored in the database as cleartext).

      Login form data is passed via POST. Any data that is taken from or generated from the user will be passed through a sanitization function to prevent SQL injection attacks.

      To track the user's state, I am looking into using session variables. My current problem is how to determine if the user has been authenticated properly, ideally without having to make a database call on every single page where this needs to be verified.

      Does anyone have any suggestions as to some ways to authenticate the contents of a session to prevent man-in-the-middle/replay attacks? The obvious way would be to store the session ID in the database and check it every time, but that adds a lot of overhead.

      Also, if anyone can spot any glaring security issues that I've missed in the descriptions above, I'd really like to hear about it. I want to do this right the first time.

      Source: http://community.livejournal.com/php/523861.html

    15. Search Engine

      Date: 12/23/06 (Web Hosts)    Keywords: database, google

      Does anyone have any suggestions for a search engine script that I can use for my site? I'd like to allow users to search for things within my site [primarily videos], but the problem seems to hinge on the fact that I don't use databases to drive my site.

      I wouldn't mind creating the search index myself, I just want something nice and clean to display results and all that. I looked at the option of adding a Google custom search engine to my site but I don't much like the branding and ads.

      Any suggestions would be awesome!

      Source: http://community.livejournal.com/webhosts/37707.html

    16. Windows file management with PHP?

      Date: 12/24/06 (PHP Community)    Keywords: php, browser, database, web

      I was curious where to look for info on how to access files and directories (and any constructs/modules/functions) that may help with file management in a Windows environment? Or any changes that need to be made to php.ini or any other file. Basically I want to be able to access and control files and folders from within a webbrowser or a command line with this script and be able to have it store filenames, data structures, etc. to my database. Also wouldn't mind some data mining functions as well, as windows search doesn't work too well and I'm still trying to find a good grep for windows.

      Thanks,
      exeyel

      Source: http://community.livejournal.com/php/525638.html

    17. html:submit vs. html:submit onclick="submitForm()"

      Date: 12/27/06 (Web Development)    Keywords: database, jsp

      quick question for the gurus here.
      i've inherited someone's code at work.
      the page is a little form. JSP. struts.
      1 text field (date), 1 dropdown to select from. 'submit' button.
      there is validation (prior to submitting) of the date. if date is invalid, the page reloads w/out resetting the data.
      on submit, a row is written to the database. there should always be 1 row on submit.

      problem: sometimes, the page submits 2 rows.

      originally, the 'submit' button was written as
      Submit

      then it was changed to
      Submitit>

      then back to the first one.

      i've tried looking up the cases where one should/shouldn't use plain submit vs. onclick"SubmitForm()", but so far i'm coming up emptyhanded.

      could someone please explain this to me?
      thank you....

      P.S: and, of course, if someone could think of something that could be causing 2 rows to be submitted (occasionally), that would be even better. btw, the 'submit' button is only being clicked ONCE when 2 rows get created.

      UPD: it seems that occasional duplication happens only when onClick is part of the submit. when onClick is removed and it's just the submit, i can't produce the duplication no matter what. question: why is onClick causing the occasional duplication (at least in part)?

      Source: http://community.livejournal.com/webdev/380061.html

    18. How to save the file to my server?

      Date: 12/29/06 (PHP Community)    Keywords: database

      Hello! Can anyone help me with saving the file to it server? Because currently i manage to upload the file into my database but not to the server itself. I know i have to use a function known as the move_upload_file but i'm uncertain how on how i can move it to this directory C:\Program Files\mysite\images. Please help! thanks a lot for the help. :)


      0)
      {
      $fileName = $_FILES['userfile']['name'];
      $tmpName = $_FILES['userfile']['tmp_name'];
      $fileSize = $_FILES['userfile']['size'];
      move_uploaded_file($fileName,$tmpName);
      $filename= "\Inetpub\wwwroot\tpi\images\$fileName"; //?? this is the part i'm facing

      if(!get_magic_quotes_gpc())
      {
      $fileName = addslashes($fileName);
      }



      $query = "INSERT INTO languages (name) ".
      "VALUES ('$fileName')";

      mysql_query($query) or die('Error, query failed');

      echo "
      File $fileName uploaded
      ";
      }
      ?>

      Source: http://community.livejournal.com/php/526096.html

    19. Checkbox to "select" content in textarea and insert into database

      Date: 12/31/06 (PHP Community)    Keywords: php, database, java

      I don't know whether if this is a PHP or Javascript question, or both?

      I'm working with many checkboxes and textareas and they are both side to side.

      By ticking many/one checkbox(es), content in "selected" textareas will be saved into the database when i click the submit button.
      But how? Has it got something to do with the values of the checkbox?

      Is this done just by PHP or do i need to use Javascript?
      I need some hints, thanks! (:

      //below is a while loop to generate table rows and increment in values (of the name [textarea1,2,3 and so on])
      $number_t=1;
      $number_c=1;
      $value_c=1;
      // Get each row of data on each iteration until there are no more rows
      while($row = mysql_fetch_array($result)){
      echo "
    ";
    echo $row['ph_name'];
    echo "
    ";
    echo $row['text'];
    echo "
    ";
    echo ""; //this part is for a Javascript function that checks the checkbox when textarea is filled in
    echo "
    ";
    echo "echo "name='cbox";
    echo $number_c;
    echo "' value='";
    echo $value_c;
    echo "' '>";
    echo "
    Previous page  ||  Next page


    antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home