Jump to content

acap89

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

acap89's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. How about POST in there.. is that right?... i think it should be GET.. i dont know the GET and POST concept...can someone elaborate
  2. already do that, the error appear= Server error The website encountered an error while retrieving http://www.pskk.org/LMS/LMSscripts/FirstTimeUser.php?Username=143409. It may be down for maintenance or configured incorrectly.
  3. $_POST['Username'] = $un = $query = SELECT * FROM student WHERE Username=149090 1 Array ( [0] => Array ( [Name] => asyraf [MatricNo] => 149090 [username] => 149090 [Password] => 149090 [Course1] => ECC3302 [Course2] => ECC4205 [Course3] => ECC4204 [Course4] => ECC4201 [Course5] => ) ) 1 this output on my browser
  4. <?php $un = $_POST['Username']; // connect to the db $mysql_host = "localhost"; $mysql_database = "****"; $mysql_user = "*****"; $mysql_password = "*****"; $conn = mysql_connect($mysql_host,$mysql_user,$mysql_password); mysql_select_db($mysql_database,$conn); $query = "SELECT * FROM student WHERE Username=149090"; //$result = mysql_query($query); /*$result = mysql_query($query) or die(mysql_error()); echo mysql_num_rows($result);*/ //Store all the course code into an array //$course_code = mysql_fetch_array($result); echo '$_POST[\'Username\'] = '.$_POST['Username'].'<br/>'; echo '$un = '.$un.'<br/>'; echo '$query = '.$query.'<br/>'; $result = mysql_query($query) or die(mysql_error()); echo mysql_num_rows($result).'<br/>'; while($row = mysql_fetch_assoc($result)){ $result_array[] = $row; } print_r($result_array); //verification if(mysql_num_rows($result) == 1) { echo 1; // for correct login response $format = ".txt"; $output = $un.$format; $fh = fopen($output,'w') or die ("Can't open file"); for($num=1;$num<=5;$num++) { $code = $course_code['Course'.$num]; fwrite($fh,$code."\r\n"); } chmod($output,0777); //chmod the file to 0777 fclose($fh); } else { echo 0; // for incorrect login response } ?> its appear this in my browser if use this code $_POST['Username'] = $un = $query = SELECT * FROM student WHERE Username=149090 1 Array ( [0] => Array ( [Name] => asyraf [MatricNo] => 149090 [username] => 149090 [Password] => 149090 [Course1] => ECC3302 [Course2] => ECC4205 [Course3] => ECC4204 [Course4] => ECC4201 [Course5] => ) ) 1
  5. No, the mysql_num_rows() function returns the amount of rows in the result, not in the database. It means that your query resulted in 4 rows (4 results WHERE Username=$un). means, there nothing wrong with database right?.
  6. nothing appear.... just a blank page...
  7. $un = $_POST['Username']; how about this one... 'Username' is from the android apps login that going to this FirstTimeUser.php the total user in the databse is 4, so the rows is 4
  8. it shows 40 i think 4 from the total username in database, 0 from the echo 0
  9. i already replace POSR with GET. it appear - Login unsuccessful, please ensure you are using the correct details Im doing the android project that need the login page... the user will key in their username in the apps and the username will go to this php code in the server.
  10. owh... then, when we can use POST method?... can elaborate more?
  11. <?php if ($_SERVER['REQUEST_METHOD'] == 'POST'){ $db = mysql_connect("localhost", "*******" , "*****")or die("Error connecting to database: " . mysql_error()); $db_used = mysql_select_db("pskkorg_drp1", $db)or die("Could not select database: " . mysql_error()); $user_name = mysql_real_escape_string($_POST['username'],$db); $query = mysql_query("SELECT * FROM student WHERE Username = '$user_name'",$db) or die(mysql_error()); if(mysql_num_rows($query) == 1){ echo "Login successful, welcome back " . $user_name . ""; }else{ echo "Login unsuccessful, please ensure you are using the correct details"; } }else{ echo "Error"; } ?> take a look at this code, is there anything wrong?... it always come out the error output when i test it. when i enter this url, http://www.pskk.org/LMS/LMSscripts/FirstTimeUser10.php?Username=149090 it come out Error. suppose it will appear Login Successful since the username 149090 exist in the database.
  12. <?php $un = $_POST['Username']; // connect to the db $mysql_host = "localhost"; $mysql_database = "****"; $mysql_user = "*****"; $mysql_password = "*****"; $conn = mysql_connect($mysql_host,$mysql_user,$mysql_password); mysql_select_db($mysql_database,$conn); $query = "SELECT * FROM student WHERE Username='$un'"; $result = mysql_query($query); //Store all the course code into an array $course_code = mysql_fetch_array($result); //verification if(mysql_num_rows($result) == 1) { echo 1; // for correct login response $format = ".txt"; $output = $un.$format; $fh = fopen($output,'w') or die ("Can't open file"); for($num=1;$num<=5;$num++) { $code = $course_code['Course'.$num]; fwrite($fh,$code."\r\n"); } chmod($output,0777); //chmod the file to 0777 fclose($fh); } else { echo 0; // for incorrect login response } ?> im doing the Learning Management System application. this FirstTimeUser.php will connect to the database and list out the coursecode in .txt take a look at my code, the output is always 0. I already stuck on how to get 1. The connection for the php to mysql is correct. the username also exist in the database. is there any suggestion on how to debug it. i dont know, its like a simple coding, but its not working... please leave some suggestion...
×
×
  • 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.