Jump to content

Problem With Php


gmz1023

Recommended Posts

Okay--so i've been working on a PHP login script (and i know its probably not secure, doesnt need to be). however i'm just now getting an error from it.heres the login codeheres the error code

<?php require("i_nc/functions.php"); if ((!isset($_GET["user"])) && (!isset($_GET["pass"])) ) {  redirect("index.php","Security Check : Hacker Attempt"); exit; } $user=$_GET["user"]; $pass=$_GET["pass"]; $fp=fopen("i_nc/users.db","r"); $userdata=array(); $redirect=""; while (($userdata = fgetcsv($fp, 1000, ",")) !== FALSE) {   if (($userdata[0]==$user) && ($userdata[1]==$pass))   { $redirect=$userdata[2]; } } fclose($fp); if ($redirect=="") {   redirect("index.php","Security Check : Fail"); } else {   setcookie("user",$user,time()+3600,"/");   setcookie("pass",$pass,time()+3600,"/");   redirect($redirect,"Security Check : Success"); } exit;?><html><head><title>Security check</title></head><body><pre> User entered : <?php print ($user . "/" . $pass)  if ($redirect<>"") {print("OK -> ".$redirect); } else {print("KO -> index"); } for ($i=0;$i<count($userdata);$i++) {  print($userdata[0] . "|" . $userdata[1] . "|" . $userdata[2] . "\n" ); }?></pre></body></html>

 User entered : "") {print("OK -> ".$redirect); } else {print("KO -> index"); } for ($i=0;$i

i realize its probably something stupid i've done, but hey... i cant figure it out lol

Link to comment
Share on other sites

Actually, you have a few mistakes:<?phpprint ($user . "/" . $pass); // missing semi-colon on this lineif ($redirect!="") {print("OK -> ".$redirect); } else {print("KO -> index"); } // I believe "<>" is not a PHP operator, != is the PHP equivalentfor ($i=0;$i<count($userdata);$i++){ print($userdata[0] . "|" . $userdata[1] . "|" . $userdata[2] . "\n" ); // I'm not sure what the loop is for if you're printing the same thing on each iteration}?>EditDo you usually program in ASP or Visual Basic?The <> operator and print command are from that.While print() is valid in PHP, echo is much preferrable, it runs faster.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...