<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[PHP Forums - PHP/MySql Login Verification]]></title>
	<link rel="self" href="http://www.phpforums.org/feed-atom-topic32.xml"/>
	<updated>2012-02-06T10:13:36Z</updated>
	<generator>PunBB</generator>
	<id>http://phpforums.org/topic32-phpmysql-login-verification.html</id>
		<entry>
			<title type="html"><![CDATA[Re: PHP/MySql Login Verification]]></title>
			<link rel="alternate" href="http://phpforums.org/post352.html#p352"/>
			<content type="html"><![CDATA[<p>if you dont want to create these file than you need to add the above mentioned code in the same file and all the files makes task a little bit complex so better you must create the two files</p>]]></content>
			<author>
				<name><![CDATA[Vinil]]></name>
				<uri>http://phpforums.org/user249.html</uri>
			</author>
			<updated>2012-02-06T10:13:36Z</updated>
			<id>http://phpforums.org/post352.html#p352</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP/MySql Login Verification]]></title>
			<link rel="alternate" href="http://phpforums.org/post70.html#p70"/>
			<content type="html"><![CDATA[<p>Hi .. Yes You have to create these two files </p><p>include &#039;library/config.php&#039;;<br />Inside the above file you can put code some thing like this<br /></p><div class="codebox"><pre><code>&lt;?php
$host = &quot;localhost&quot;;//Your mysql host name
$user = &quot;root&quot;;  //Username to access the database;
$pass = &quot;password&quot;;//Password to access the database;
$db = &quot;_db_name&quot;;//The database where you created the tables
?&gt;</code></pre></div><br /><p>include &#039;library/opendb.php&#039;;</p><p>then in opendb.php add the following code<br /></p><div class="codebox"><pre><code>&lt;?php
mysql_connect(  $host, $user, $pass  ) or die( mysql_error() );
mysql_select_db(  $db );
?&gt;</code></pre></div><br /><p>Try this .. have a nice time ..</p>]]></content>
			<author>
				<name><![CDATA[aneeshrp]]></name>
				<uri>http://phpforums.org/user46.html</uri>
			</author>
			<updated>2010-08-06T07:20:11Z</updated>
			<id>http://phpforums.org/post70.html#p70</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[PHP/MySql Login Verification]]></title>
			<link rel="alternate" href="http://phpforums.org/post65.html#p65"/>
			<content type="html"><![CDATA[<p>Hey guys,&nbsp; I&#039;m a new web developer doing things kinda out of my reach so if I sound stupid I&#039;m sorry.&nbsp; I am trying to create a mysql database with usernames and passwords which php will connect to and verify, then in turn redirect the user accordingly.&nbsp; I found a script that does just that but I have some questions about it.<br />I created the Mysql database as such...<br /></p><div class="codebox"><pre><code>CREATE TABLE tbl_auth_user (
user_id VARCHAR(10) NOT NULL,
user_password CHAR(32) NOT NULL,

PRIMARY KEY (user_id)
);

INSERT INTO tbl_auth_user (user_id, user_password) VALUES (&#039;theadmin&#039;, PASSWORD(&#039;chumbawamba&#039;));
INSERT INTO tbl_auth_user (user_id, user_password) VALUES (&#039;webmaster&#039;, PASSWORD(&#039;webmistress&#039;));


//Now that that is created I looked at the PHP code and this is what I have questions on.

&lt;?php
// we must never forget to start the session
session_start();

$errorMessage = &#039;&#039;;
if (isset($_POST[&#039;txtUserId&#039;]) &amp;&amp; isset($_POST[&#039;txtPassword&#039;])) {
   include &#039;library/config.php&#039;;
   include &#039;library/opendb.php&#039;;

   $userId = $_POST[&#039;txtUserId&#039;];
   $password = $_POST[&#039;txtPassword&#039;];

   // check if the user id and password combination exist in database
   $sql = &quot;SELECT user_id
           FROM tbl_auth_user
           WHERE user_id = &#039;$userId&#039;
                 AND user_password = PASSWORD(&#039;$password&#039;)&quot;;

   $result = mysql_query($sql)
             or die(&#039;Query failed. &#039; . mysql_error());

   if (mysql_num_rows($result) == 1) {
      // the user id and password match,
      // set the session
      $_SESSION[&#039;db_is_logged_in&#039;] = true;

      // after login we move to the main page
      header(&#039;Location: main.php&#039;);
      exit;
   } else {
      $errorMessage = &#039;Sorry, wrong user id / password&#039;;
   }

   include &#039;library/closedb.php&#039;;
}
?&gt;</code></pre></div><p>The part that confuses me is the library directory.&nbsp; Do I actually have to create a library directory and the files called closedb.php and opendb.php or is this some apache built in server feature.&nbsp; If i do need to create the directory... are these files already created?&nbsp; The reason I ask is because in the tutorial he gave no source to these files, so I am wondering if they are a standard web script that can be obtained someplace.</p><p>Thank you for any input you may have in advance,<br />Squeaker2</p>]]></content>
			<author>
				<name><![CDATA[squeaker2]]></name>
				<uri>http://phpforums.org/user44.html</uri>
			</author>
			<updated>2010-07-25T22:46:03Z</updated>
			<id>http://phpforums.org/post65.html#p65</id>
		</entry>
</feed>

