Jump to content

jokeascool

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jokeascool's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello All, I am having a problem with a bit of code. I believe my logic is off somewhere and a fresh pair of eyes may help. I know that I can access the db and get the information. The problem is if I enter incorrect password or username it still sends me to the welcome page. Where as if the login info is wrong I want to go to index2 to have them try again. No matter what I enter it takes me to the welcome page. Could you please tell me what I am doing wrong. [code] <?php session_start(); unset($uname); unset($pword);     $host="localhost:3306"; $user="username"; $lipassword="password"; $database="bfcc"; $uname=$_POST['fusername']; $pword=$_POST['password']; $connection=mysql_connect($host,$user,$lipassword)             or die ("Problems Connecting to Server");              $db=mysql_select_db($database,$connection)             or die ("Could not create connection with the database");              $query="SELECT * FROM users WHERE username = '$uname' AND password = '$pword'"; $result=mysql_query($query,$connection)             or die("Could not execute query"); if (!mysql_num_rows($result)) {   header("Location: index2.php"); } header("Location: welcome.php");              mysql_close($connection); ?> [/code] Thanks Joe [b]Mod Edit(shoz): connection details removed[/b]
  2. [!--quoteo(post=374790:date=May 17 2006, 05:26 PM:name=ryanlwh)--][div class=\'quotetop\']QUOTE(ryanlwh @ May 17 2006, 05:26 PM) [snapback]374790[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code]If($row==0) {   echo: "No records found"; }[/code] Here, $row is an array, so it will never "equal" to zero. The following is how you should do it. [code]If(count($row)==0) {   echo: "No records found"; }[/code] [/quote] Could someone please explain briefly how PHP interpets code. Does it do so line by line or some way else. The reason I ask is to be able to trouble shoot if it is doing it logically the error will be in line 29. However anyway else the error could be anywhere and just triggered by some action taken by line 29. I guess some newbie trouble shooting tips would be helpful. Thanks Joe PS. Sorry for the crappy spelling and punctuation. Nature calls. HEHE
  3. Here is the code as it stands. I added the extra semi colon, plus a line to see if the query comes back null. Let me know what you think. [code]<?php $host="localhost"; $user="jkaskel"; $password="tasha1"; $database="bfcc"; $uname=$_Post['username']; $pword=$_Post['password']; $connection=mysql_connect($host,$user,$password)             or die ("Problems Connecting to Server");              $db = mysql_select_db($database,$connection)             or die ("Could not create connection with the database");                          $valid=0; $query="Select * from users where username='$uname'"; $result=mysql_query($query)             or die("Could not execute query"); $row = mysql_fetch_array($result); extract($row); If($row==0) {   echo: "No records found"; } if($pword == $password) {   header("location:loginok.php"); } else {   header("location:index.php"); } ?> [/code] Thanks Joe
  4. [!--quoteo(post=374716:date=May 17 2006, 12:34 PM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ May 17 2006, 12:34 PM) [snapback]374716[/snapback][/div][div class=\'quotemain\'][!--quotec--] why don't you print out your error here as well as double check to make sure you've got ALL your code listed. [/quote] Here is the error I am Recieving: Parse error: syntax error, unexpected T_VARIABLE in V:\Core\htdocs\login.php on line 29 Thanks Joe P.S. That was all of the code.. I was trying to test that much as a simple program and then expand from those fundementals.
  5. [!--quoteo(post=374680:date=May 17 2006, 11:09 AM:name=obsidian)--][div class=\'quotetop\']QUOTE(obsidian @ May 17 2006, 11:09 AM) [snapback]374680[/snapback][/div][div class=\'quotemain\'][!--quotec--] welcome to the forums! hope you find lots of great help here you're missing the semicolon on the line before: [code] $result=mysql_query($query) or die("Could not execute query") [/code] good luck! [/quote] Thank you very much.. Still getting parse error however. See anything else that stands out a wrong or bad coding? Thanks Joe
  6. Hello all, I am new to php and I am just playing around at this point. I am trying to right a simple login script and I am getting some parse errors. Could you please review the following code and give any suggestions. <?php $host="localhost"; $user="jkaskel"; $password="tasha1"; $database="bfcc"; $uname=$_Post['username']; $pword=$_Post['password']; $connection=mysql_connect($host,$user,$password) or die ("Problems Connecting to Server"); $db = mysql_select_db($database,$connection) or die ("Could not create connection with the database"); $valid=0; $query="Select * from users where username='$uname'"; $result=mysql_query($query) or die("Could not execute query") [!--coloro:#3366FF--][span style=\"color:#3366FF\"][!--/coloro--]$row = mysql_fetch_array($result);[!--colorc--][/span][!--/colorc--]***this line is giving a parse error. extract($row); if($pword == $password) { header("location:loginok.php"); } else { header("location:index.php"); } ?> Thank you for your help and support! Joe
×
×
  • 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.