Jump to content

Authentication and an event and if statment to stop execution.


todayme

Recommended Posts

I have the following lines of code I need to valuate what is in $data and if it doesnt match the string I need it to exit execution.  I am a newbie any ideas?

 

 

$data = mysql_query("SELECT * FROM _User WHERE Email = '$dbemail' AND Password = '$dbpassword'")

or die(mysql_error());


$data = mysql_query("SELECT * FROM _User WHERE Email = '$dbemail' AND Password = '$dbpassword'")
or die(mysql_error());

$result = mysql_fetch_array($data);

if(mysql_num_rows($result) < 1)
     exit();

 

 

 

I have tried the mysql_num_rows before but it didnt like it.  I just tried your code and got this error.

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/admin/domains/sold.au.com/public_html/test.php on line 27

 

 

ooops sorry my mistake

 

it should be

 

mysql_num_rows($data)

 

and not

mysql_num_rows($result)

 

 

 

I have the code below it works if authentication fails, but if authentication is okay it doesnt do anything.......... do your if statments have end if in the syntax?  I cant see that it does, thats what I know from VB........ I tried elseif = 1 keep going but that doesnt work either ...........any ideas.........by the way thanks heaps for help

you can use

 

if(mysql_num_rows($result) < 1)
     exit();
else
{
              /// your code goes here what you want to if there is record in db....
}

 

 

 

 

Parse error: syntax error, unexpected T_ELSE in /home/admin/domains/sold.au.com/public_html/test.php on line 33

 

Sorry to be a pain but any ideas on that the code looks all good to me ........not that that means alot ha ha

post the code of test.php

 

then I can tell where is the problem

 

 

<?

 

//set the variables as required

$dbhost = "localhost";

$dbuser = "admin_sex";

$dbpass = "sex";

$dbname = "admin_sex";

$dbemail = $_POST['email'];

$dbpassword = $_POST['password'];

 

 

 

//do not edit this, it connects the script

$db = mysql_pconnect($dbhost,$dbuser,$dbpass);

mysql_select_db($dbname) or die(mysql_error());

 

// Collects data from "friends" table

//$data = mysql_query("SELECT * FROM _User")

 

 

 

$data = mysql_query("SELECT * FROM _User WHERE Email = '$dbemail' AND Password = '$dbpassword'")

or die(mysql_error());

 

$result = mysql_fetch_array($data);

 

if(mysql_num_rows($data) < 1)

 

Print "Authentication Failed";

 

exit();

 

 

 

elseif

 

{

 

 

 

 

// puts the "friends" info into the $info array

$info = mysql_fetch_array( $data );

 

// Print out the contents of the entry

Print "<b>Account ID:</b> ".$info['ID'] . " <br>";

 

 

$userid = $info['ID'];

 

 

 

Print "<b>Name:</b> ".$info['Name'] . " ";

Print "<b>Email:</b> ".$info['Email'] . " ";

Print "<b>Password:</b> ".$info['Password'] . " <br>";

 

 

 

 

 

 

 

 

unset($info);

 

Print "<br>";

Print "<br>";

 

// Collects data from "friends" table

$data = mysql_query("SELECT * FROM _Leads WHERE LINKID = '$userid'")

or die(mysql_error());

 

// puts the "friends" info into the $info array

 

 

for($i = 0; $i < 3; $i++) {

 

 

 

 

$info = mysql_fetch_array( $data );

 

 

 

// Print out the contents of the entry

 

 

 

Print "<b>ID:</b> ".$info['ID'] . " ";

Print "<b>Link ID:</b> ".$info['LINKID'] . " ";

 

Print "<b>Industry:</b> ".$info['Industry'] . " ";

Print "<b>Location:</b> ".$info['Location'] . " ";

Print "<br>";

 

}

 

unset($info);

 

 

mysql_close($db);

 

}

 

?>

 

 

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.