Jump to content

Check whether the username exists, registration authentication.


ubuntu

Recommended Posts

Dear all,

 

Below is my coding, I don't know what's wrong with this, the output is a blank page. Is it any syntax error or I miss something else?

 

$connection = mysql_connect("$host", "$user", "$password")
     or die(mysql_error());
$db = mysql_select_db($database, $connection) or die(mysql_error());

//build and issue query
$sql = "SELECT * FROM pendaftaran WHERE
username = '$_POST['username']'";

$result = mysql_query($sql) or die (mysql_error());

//get the number of rows in the result set
$num = mysql_numrows($result);

//if the username exists, print the message
if ($num != 0) {
     die("The Username '$_POST['username']' already exists, please select another username.");

}

 

Your advice or suggestion are most welcome. Thank you for your kind attention.

This should throw a syntax error:

 

<?php
// ffixed version
die("The Username " . $_POST['username'] . " already exists, please select another username.");

}

 

<?php
$num = mysql_numrows($result);

//should be
$num = mysql_num_rows($result);

 

<?php
//build and issue query
$sql = "SELECT * FROM pendaftaran WHERE
username = '" . $_POST['username'] . "'"; // syntax issue here also.

 

It seems you have turned off error reporting, probably not the best idea for development.

You can turn on error reporting in your php.ini file in /etc/php5/apache2

 

I have noticed that Ubuntu (6.01 is what I run) does not report errors very well. I have it set to E_ERROR, and I don't get the same feedback as my windows xp machine running XAMPP also set to E_ERROR

 

or to turn on error reporting for some pages, you can use at the top of the pages you want it to report on

 

error_reporting(E_WARNING);

ini_set('display_errors', '1');

 

 

Archived

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

×
×
  • 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.