<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1039090" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1039090</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/spot-problem-script-please#comment-1222101</link>
    <description> &lt;p&gt;so now what happens is if either field was blank it assigns a variable to the word &quot;true&quot; else variable is &quot;false&quot;&lt;/p&gt;
&lt;p&gt;then, if var is false (that is neither field was blank) it connects to the DB and checks the users input&lt;br /&gt;
else, it goes to the login retry page informing user he didnt input anything and this also means it doesnt unnecessarily access and check the DB&lt;/p&gt;
&lt;p&gt;The whole script now seems a little sloppy and bloated to me, but it works, and I dont like fixing things that work &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/big.png&quot; title=&quot;Laughing out loud&quot; alt=&quot;Laughing out loud&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;My problem now is it ALWAYS sets the $_SESSION[&#039;loginerror&#039;] to the number 3&lt;/p&gt;
&lt;p&gt;this is because of my sql query line&lt;br /&gt;
SELECT * FROM tablename WHERE username=&#039;$username&#039; and password=&#039;$password&#039;&lt;/p&gt;
&lt;p&gt;So it will only retireve data if BOTH match&lt;br /&gt;
so when my following script determines which input was incorrect, i.e. the username OR password, both will be, always&lt;/p&gt;
&lt;p&gt;because even if the user inputted the correct username OR password, it wont match the DB as the DB data will be blank because BOTH didnt match in the DB querey&lt;/p&gt;
&lt;p&gt;how do I get it to select ANY of password and username when they match without having 2 seperate sql queries?&lt;/p&gt;
&lt;p&gt;the updated script...&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;session_start&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;();&lt;br /&gt;require_once(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;mysql.php&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;br /&gt;if (!&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;username&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;] || !&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;password&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]) {&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$blank_login &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;true&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_SESSION&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;loginerror&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;] = &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;} else {&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$blank_login &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;false&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$blank_login &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;false&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) {&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;mysql_select_db&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;DBNAME&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) or die(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;mysql_error&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;());&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$username&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;username&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;];&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$password&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;password&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;];&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;SELECT * FROM tablename WHERE username=&#039;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$username&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039; and password=&#039;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$password&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;mysql_query&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$sql&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$username &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;username&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;] &amp;amp;&amp;amp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$password &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;password&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]) {&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_SESSION&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;user&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]=&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$username&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Location: /members/memindex.php&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;); &lt;br /&gt;} else {&lt;br /&gt;&lt;br /&gt;if (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$username &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;!= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;username&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;] &amp;amp;&amp;amp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$password &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;!= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;password&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]) {&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_SESSION&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;loginerror&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]=&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;} elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$username &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;username&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]) {&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_SESSION&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;loginerror&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]=&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;} elseif (&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$password &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;== &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$result&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;password&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]) {&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_SESSION&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;loginerror&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]=&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;header&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Location: loginerr.php&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;); &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
 </description>
     <pubDate>Tue, 24 Jul 2007 13:15:37 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1222101 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/spot-problem-script-please#comment-1222099</link>
    <description> &lt;p&gt;RATHER THAN edit this entire post(incase someone is reading/replying to it) I have solved this problem...see next post for script changes&lt;br /&gt;
but still have another problem (next post)&lt;/p&gt;
&lt;p&gt;I tried it and made no difference, but I did discover something&lt;/p&gt;
&lt;p&gt;the original script sets a value to a session then redirects the user with the header code&lt;/p&gt;
&lt;p&gt;I changed it to just echo some text and it worked fine??&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;if (!$_POST[&amp;#039;username&amp;#039;] || !$_POST[&amp;#039;password&amp;#039;]) {&lt;br /&gt;echo &amp;quot;blank&amp;quot;;&lt;br /&gt;}&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;so there is something wrong with the header redirect within an if statement? I have seen people use a variable within the clause&lt;/p&gt;
&lt;p&gt;if (!$_POST[&#039;username&#039;] || !$_POST[&#039;password&#039;]) {&lt;br /&gt;
$blank_login = &#039;true&#039;;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;then later have IF $blank_login == &#039;true&#039; then do whatever&lt;/p&gt;
&lt;p&gt;It seems to me that header(&quot;Location: loginerr.php&quot;);  isnt working correctly for some reason. because its in within the if statement?&lt;/p&gt;
&lt;p&gt;To be honest, it might be fine, but I am not happy with the script that checks the users inputs to the data from the DB checks....&lt;br /&gt;
&lt;code&gt;if($username == $result[&amp;#039;username&amp;#039;] &amp;amp;&amp;amp; $password == $result[&amp;#039;password&amp;#039;]) {&lt;/code&gt;&#039;&lt;/p&gt;
&lt;p&gt;$username is assigned to $_POST[&#039;username&#039;]&lt;br /&gt;
and of course $result[&#039;username&#039;] is the data from the DB&lt;/p&gt;
&lt;p&gt;but if the users left the fields blank, they wont match anything in the DB, so the DB data will be blank&lt;br /&gt;
and so is the users input&lt;br /&gt;
so that above code is returned as TRUE&lt;/p&gt;
&lt;p&gt;and therefore logs in the user. there must be a better way to check if the info the user puts in a form matches anything in the DB&lt;/p&gt;
 </description>
     <pubDate>Tue, 24 Jul 2007 12:12:40 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1222099 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/spot-problem-script-please#comment-1222072</link>
    <description> &lt;p&gt;You only have one pipe bar in your first logical OR.&lt;/p&gt;
&lt;p&gt;if (!$_POST[&#039;username&#039;] | !$_POST[&#039;password&#039;]) {&lt;/p&gt;
&lt;p&gt;needs to be&lt;/p&gt;
&lt;p&gt;if (!$_POST[&#039;username&#039;] || !$_POST[&#039;password&#039;]) {&lt;/p&gt;
&lt;p&gt;I don&#039;t know if that&#039;s the only problem, but try it and see if it works.&lt;/p&gt;
 </description>
     <pubDate>Tue, 24 Jul 2007 00:09:39 +0000</pubDate>
 <dc:creator>teammatt3</dc:creator>
 <guid isPermaLink="false">comment 1222072 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
