Jump to content

Archived

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

sangasura

Login Script (Send Parameter)

Recommended Posts

This login scrip i take from dreamweaver

 

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--][span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]require_once([/span][span style=\"color:#DD0000\"]\'Connections/Con1.php\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?>

<?php

$colname_Student [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"1\"[/span][span style=\"color:#007700\"];

if (isset([/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'ICNo\'[/span][span style=\"color:#007700\"]])) {

  [/span][span style=\"color:#0000BB\"]$colname_Student [/span][span style=\"color:#007700\"]= ([/span][span style=\"color:#0000BB\"]get_magic_quotes_gpc[/span][span style=\"color:#007700\"]()) ? [/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'ICNo\'[/span][span style=\"color:#007700\"]] : [/span][span style=\"color:#0000BB\"]addslashes[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$_GET[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'ICNo\'[/span][span style=\"color:#007700\"]]);

}

[/span][span style=\"color:#0000BB\"]mysql_select_db[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$database_Con1[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$Con1[/span][span style=\"color:#007700\"]);

[/span][span style=\"color:#0000BB\"]$query_Student [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]sprintf[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"SELECT * FROM dbstudent WHERE ICNo = \'%s\'\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$colname_Student[/span][span style=\"color:#007700\"]);

[/span][span style=\"color:#0000BB\"]$Student [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$query_Student[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$Con1[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]());

[/span][span style=\"color:#0000BB\"]$row_Student [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_fetch_assoc[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$Student[/span][span style=\"color:#007700\"]);

[/span][span style=\"color:#0000BB\"]$totalRows_Student [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_num_rows[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$Student[/span][span style=\"color:#007700\"]);

[/span][span style=\"color:#0000BB\"]?>

<?php [/span][span style=\"color:#007700\"]require_once([/span][span style=\"color:#DD0000\"]\'Connections/Con1.php\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?>

<?php

[/span][span style=\"color:#FF8000\"]// *** Validate request to login to this site.

[/span][span style=\"color:#0000BB\"]session_start[/span][span style=\"color:#007700\"]();

 

[/span][span style=\"color:#0000BB\"]$loginFormAction [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]$_SERVER[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'PHP_SELF\'[/span][span style=\"color:#007700\"]];

if (isset([/span][span style=\"color:#0000BB\"]$accesscheck[/span][span style=\"color:#007700\"])) {

  [/span][span style=\"color:#0000BB\"]$GLOBALS[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'PrevUrl\'[/span][span style=\"color:#007700\"]] = [/span][span style=\"color:#0000BB\"]$accesscheck[/span][span style=\"color:#007700\"];

  [/span][span style=\"color:#0000BB\"]session_register[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\'PrevUrl\'[/span][span style=\"color:#007700\"]);

}

 

if (isset([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'IcNo\'[/span][span style=\"color:#007700\"]])) {

  [/span][span style=\"color:#0000BB\"]$loginUsername[/span][span style=\"color:#007700\"]=[/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'IcNo\'[/span][span style=\"color:#007700\"]];

  [/span][span style=\"color:#0000BB\"]$password[/span][span style=\"color:#007700\"]=[/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'Password\'[/span][span style=\"color:#007700\"]];

  [/span][span style=\"color:#0000BB\"]$MM_fldUserAuthorization [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"];

  [/span][span style=\"color:#0000BB\"]$MM_redirectLoginSuccess [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#DD0000\"]\"Index2.php?IcNo=<?php echo $row_Student[\'ICNo\']; ?>\"[/span][span style=\"color:#007700\"];

  [/span][span style=\"color:#0000BB\"]$MM_redirectLoginFailed [/span][span style=\"color:#007700\"]=[/span][span style=\"color:#DD0000\"]\"Index.php\"[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#0000BB\"]$MM_redirecttoReferrer [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]false[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#0000BB\"]mysql_select_db[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$database_Con1[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$Con1[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]$LoginRS__query[/span][span style=\"color:#007700\"]=[/span][span style=\"color:#0000BB\"]sprintf[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"SELECT ICNo, Name FROM dbstudent WHERE ICNo=\'%s\' AND Name=\'%s\'\"[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]get_magic_quotes_gpc[/span][span style=\"color:#007700\"]() ? [/span][span style=\"color:#0000BB\"]$loginUsername [/span][span style=\"color:#007700\"]: [/span][span style=\"color:#0000BB\"]addslashes[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$loginUsername[/span][span style=\"color:#007700\"]), [/span][span style=\"color:#0000BB\"]get_magic_quotes_gpc[/span][span style=\"color:#007700\"]() ? [/span][span style=\"color:#0000BB\"]$password [/span][span style=\"color:#007700\"]: [/span][span style=\"color:#0000BB\"]addslashes[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$password[/span][span style=\"color:#007700\"])); [/span][span style=\"color:#0000BB\"]$LoginRS [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$LoginRS__query[/span][span style=\"color:#007700\"], [/span][span style=\"color:#0000BB\"]$Con1[/span][span style=\"color:#007700\"]) or die([/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"]()); [/span][span style=\"color:#0000BB\"]$loginFoundUser [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_num_rows[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$LoginRS[/span][span style=\"color:#007700\"]); if ([/span][span style=\"color:#0000BB\"]$loginFoundUser[/span][span style=\"color:#007700\"]) { [/span][span style=\"color:#0000BB\"]$loginStrGroup [/span][span style=\"color:#007700\"]=[/span][span style=\"color:#DD0000\"]\"\"[/span][span style=\"color:#007700\"];[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

 

when i try to click the login page i got this error

 

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\apache\htdocs\projek\loginstudent.php on line 28

 

could some one help me resolve this thing

Share this post


Link to post
Share on other sites

it's not difficult to debug in php, just follow the error message and line number, you can debug it easily.

 

so let's focus on line 28

 


<?

.....
$MM_redirectLoginSuccess = "Index2.php?IcNo=<?php echo $row_Student['ICNo']; ?>";

?>

 

you type '<?' twice, so the error message is prompted.

 

it should be

 

...

$MM_redirectLoginSuccess = "Index2.php?IcNo=".$row_Student['ICNo']; 

...

Share this post


Link to post
Share on other sites

would probably be better:

since you have all ready called for Con1.php

you dont need too call it again, unless i am mistaken,

it obviously stores your mysql passwords etc and nothing else

like for example news garbage.

i also find it easier too break down scripts so you dont miss something when you are scanning through it

<?php 
require_once('Connections/Con1.php');

$colname_Student = "1";

if (isset($_GET['ICNo'])) 
{
$colname_Student = (get_magic_quotes_gpc()) ? $_GET['ICNo'] : addslashes($_GET['ICNo']);
}
mysql_select_db($database_Con1, $Con1);

$query_Student = sprintf("SELECT * FROM dbstudent WHERE ICNo = '%s'", $colname_Student);

$Student = mysql_query($query_Student, $Con1) or die(mysql_error());

$row_Student = mysql_fetch_assoc($Student);

$totalRows_Student = mysql_num_rows($Student);


// *** Validate request to login to this site.
session_start();

$loginFormAction = $_SERVER['PHP_SELF'];

if (isset($accesscheck)) 
{
$GLOBALS['PrevUrl'] = $accesscheck;

session_register('PrevUrl');
}

if (isset($_POST['IcNo'])) 
{
$loginUsername=$_POST['IcNo'];

$password=$_POST['Password'];

$MM_fldUserAuthorization = "";

$MM_redirectLoginSuccess = "Index2.php?IcNo=<?php echo $row_Student['ICNo']; ?>"; 

$MM_redirectLoginFailed ="Index.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_Con1, $Con1); $LoginRS__query=sprintf("SELECT ICNo, Name FROM dbstudent WHERE ICNo='%s' AND Name='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $Con1) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup ="";
?>

Share this post


Link to post
Share on other sites

but i still got an error

parse error in c:\apache\htdocs\projek\loginstudent.php on line 179

 

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]177 [span style=\"color:#0000BB\"]<?php

178 mysql_free_result[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$Student[/span][span style=\"color:#007700\"]);

[/span][span style=\"color:#0000BB\"]179 ?>[/span]

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

why?

Share this post


Link to post
Share on other sites

×

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.