christophe Posted November 10, 2006 Share Posted November 10, 2006 Hi thereI have a table in mysql database with fields like thisusername password custorsuppalex sdjjdjiaislei Cbloggs djdjjsaowe sHow would i get the value of custorsupp field from the database using phpAnd also how would i redirect a user according to this valueThanksAlex Quote Link to comment Share on other sites More sharing options...
chiprivers Posted November 10, 2006 Share Posted November 10, 2006 Hi Alex,Have you done any PHP and MySQL integration? If not, you should start with a simple tutorial like this one:[url=http://devzone.zend.com/node/view/id/641]http://devzone.zend.com/node/view/id/641[/url]I am assuming that you first want to verify a persons username and password, you can do this by querying the database for records where the username and password columns values match those entered by the user. If you have this set up correctly and the person enteres valid details, this should return one record from the database. You can then extract the value from the custorsupp column of this one record to use in proceeding. Quote Link to comment Share on other sites More sharing options...
christophe Posted November 10, 2006 Author Share Posted November 10, 2006 hi thanks for your reply yep ive verified the username and passwordbut i cant work out or find the code to get the value of custorsuppand then redirect the user according to that value which by the way would either be c for customer or s for supplier Quote Link to comment Share on other sites More sharing options...
chiprivers Posted November 10, 2006 Share Posted November 10, 2006 you will want something like this to get value of custorsup:while ($row = mysql_fetch_array($result)) { $value = $row['custorsupp'];}This will apply the value with c or s to the variable $value. What the above is doing is actually looping thorugh all records returned and doing this for each record but as there should be only one record returned it should do it just the once. Quote Link to comment Share on other sites More sharing options...
chiprivers Posted November 10, 2006 Share Posted November 10, 2006 To redirect to alternative page:<?php/** * Place in a blank PHP page */// Change to the URL you want to redirect to$URL="http://www.example.com";header ("Location: $URL");?> Quote Link to comment Share on other sites More sharing options...
fenway Posted November 10, 2006 Share Posted November 10, 2006 Remember that in general comparisons are case-insensitive, if you care. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.