PDA

View Full Version : username and password


0810
08-23-2002, 02:51 AM
I try to run this script but it is not working

my php editor says"You don't have permission to access /<br /><b>Notice</b>: Undefined variable: PHP_SELF in <b>c:/itohideo/copy.php</b> on line <b>5</b><br /> on this server."

Why it comes this message!

my php is 4.2 latest varsion

Here is code


<?php
if ( !isset($submitteduser) ):
?>
<form action="<?=$PHP_SELF?>" method="get">
<table width="40%" border="0">
<tr>
<td width="25%">Username:</td>
<td width="75%"><input name="submitteduser" type="text" size="30" maxlength="30"></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="submittedpassword" type="password" size="30" maxlength="30"></td>
</tr>
</table>
<input name="submit" type="submit" value="Logon">
</form>
<br>
<?php
$choice = 0;
else:
// Connect to the database server
$dbcnx = @mysql_connect("localhost", "itohideo", "1234");
if (!$dbcnx)
{
echo( "<p>Unable to connect to the database server at this time.</p>" );
exit();
}

// Select the database
if (! @mysql_select_db("itohideo") )
{
echo( "<p>Unable to locate the database at this time.</p>" );
exit();
}

//Select the account table
$result = @mysql_query("SELECT * FROM kk");
if (!$result)
{
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
$allcorrect = 0;
$usercorrect = 0;
while ( $row = mysql_fetch_array($result))
{
$dbuser = $row["itohideo"];
$dbpass = $row["1234"];

if ( $dbuser == $submitteduser )
{
$usercorrect = 1;
if ( $dbpass == $submittedpassword )
{
$finaluser = $row["itohideo"];
$allcorrect = 1;
}
}

}
if ( $allcorrect == 1 ):?>
Whats up <?=$finaluser?> , What would you like to do today?..<br>
<table width="50%" border="0">
<tr>
<td>
<ol>
<li>
<a href="addnews.php?username=<?=$user?>&password=<?=$pass?>">
Add News Post</a>
</li>
<li>
<a href="deletenews.php?username=<?=$user?>&password=<?=$pass?>">
Delete A News Post</a>
</li>
<li>
<a href="addshow.php?username=<?=$user?>&password=<?=$pass?>">
Add Show</a>
</li>
<li>
<a href="deleteshow.php?username=<?=$user?>&password=<?=$pass?>">
Delete Show</a>
</li>
<li>
<a href="editnewsflash.php?username=<?=$user?>&password=<?=$pass?>">
Edit The News Flash</a>
</li>
</ol>
</td>
</tr>
</table>
<?php
else:
if ( $usercorrect = 1 )
echo("Invalid Password");
else
echo("Invalid user");
endif;
endif;
?>

stuntboy
08-23-2002, 03:33 AM
try
<form action="<?=$_SERVER['PHP_SELF']?>" method="get">

instead of

<form action="<?=$PHP_SELF?>" method="get">

The Wizzard
08-23-2002, 04:22 AM
Nah, if its a problem with that piece of code, use this...

<? echo "$PHP_SELF"; ?>

0810
08-23-2002, 05:04 AM
I did both ways

but Sitll not working yet

Do you have any idea?

Thanks for helping

The Wizzard
08-23-2002, 05:29 AM
You know, I doubt this will fix it, but its worth a shot... Try this piece of code instead...

method="get" action="<? echo "$PHP_SELF"; ?>

Put the method infront of the action...

0810
08-23-2002, 06:02 AM
Thanks

I gave a shot, but it didn't work

Thank you for helping me out

I try to find my mistake

IF you have any ideas, please tell me

Thanks all

stuntboy
08-23-2002, 06:06 AM
if register_globals is off (and it is off by default on your version of php) $PHP_SELF is not defined. you will need to refer to it with $_SERVER['PHP_SELF']. It is possible short tags <?= ?> thing is disabled as well.

$_SERVER['SCRIPT_NAME'] might possibly work for you as well

0810
08-23-2002, 06:39 AM
seems to work

when I clicked send, next page was jsut "The page cannot be found".

Is it soemthing wrong.

Please tell me any idea to solve this problem

Thanks

stuntboy
08-23-2002, 06:43 AM
when it says page cannot be found what is the address in the address bar?

I am done for the night my mouse is dead and I am tired of navigating with my keyboard lol

0810
08-23-2002, 06:52 AM
it says

http://localhost/$_SERVER['SCRIPT_NAME']?submitteduser=itohideo&submittedpassword=1234&submit=Logon"

like this

Do you have any idea?


Thanks

stuntboy
08-23-2002, 06:43 PM
I should have said use
<form action="<?=$_SERVER['SCRIPT_NAME']?>" method="get">

or

<form action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="get">

0810
08-24-2002, 05:53 AM
stuntboy hi how are you?

I did your way but when i click Send button, it doesn't come anything. Just like "Reset button"

It suppose to come messages

but nothing

bar says "http://localhost/copy.php?submitteduser=itohideo&submittedpassword=1234&submit=Logon"

stuntboy do you have any idea?

Thanks

stuntboy
08-24-2002, 03:04 PM
Ok that part is working properly, the other bit looks to be just some missing or misplaced endif's in there as the form tag is working as it should be. Running some tests now :)

stuntboy
08-24-2002, 03:16 PM
was not the endif's

<?php
if ( !isset($_GET['submitteduser']) ):
?>
<form action="<?=$_SERVER['$SCRIPT_NAME']?>" method="get">
<table width="40%" border="0">
<tr>
<td width="25%">Username:</td>
<td width="75%"><input name="submitteduser" type="text" size="30" maxlength="30"></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="submittedpassword" type="password" size="30" maxlength="30"></td>
</tr>
</table>
<input name="submit" type="submit" value="Logon">
</form>
<br>
<?php
$choice = 0;
else:
// Connect to the database server
$dbcnx = @mysql_connect("localhost", "itohideo", "1234");
if (!$dbcnx)
{
echo( "<p>Unable to connect to the database server at this time.</p>" );
exit();
}

// Select the database
if (! @mysql_select_db("itohideo") )
{
echo( "<p>Unable to locate the database at this time.</p>" );
exit();
}

//Select the account table
$result = @mysql_query("SELECT * FROM kk");
if (!$result)
{
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
$allcorrect = 0;
$usercorrect = 0;
while ( $row = mysql_fetch_array($result))
{
$dbuser = $row["itohideo"];
$dbpass = $row["1234"];

if ( $dbuser == $_GET['$submitteduser'] )
{
$usercorrect = 1;
if ( $dbpass == $_GET['$submittedpassword'] )
{
$finaluser = $row["itohideo"];
$allcorrect = 1;
}
}

}
if ( $allcorrect == 1 ):?>
Whats up <?=$finaluser?> , What would you like to do today?..<br>
<table width="50%" border="0">
<tr>
<td>
<ol>
<li>
<a href="addnews.php?username=<?=$user?>&password=<?=$pass?>">
Add News Post</a>
</li>
<li>
<a href="deletenews.php?username=<?=$user?>&password=<?=$pass?>">
Delete A News Post</a>
</li>
<li>
<a href="addshow.php?username=<?=$user?>&password=<?=$pass?>">
Add Show</a>
</li>
<li>
<a href="deleteshow.php?username=<?=$user?>&password=<?=$pass?>">
Delete Show</a>
</li>
<li>
<a href="editnewsflash.php?username=<?=$user?>&password=<?=$pass?>">
Edit The News Flash</a>
</li>
</ol>
</td>
</tr>
</table>
<?php
else:
if ( $usercorrect = 1 )
echo("Invalid Password");
else
echo("Invalid user");
endif;
endif;
?>


I think I got them all though I may have missed some. all variables that come from your form that is using the get method must be refered to with $_GET['theVarName']

0810
08-25-2002, 10:02 PM
stuntboy hi how are you doing?

it is not working yet. My php editor says"You don't have permission to access /<br /><b>Notice</b>: Undefined index: $SCRIPT_NAME in <b>c:/itohideo/copy.php</b> on line <b>4</b><br /> on this server."

also add bar"http://localhost/<br%20/><b>Notice</b>:%20%20Undefined%20index:%20%20$SCRIPT_NAME%20in%20<b>c:/itohideo/copy.php</b>%20on%20line%20<b>4</b><br%20/>?submitteduser=itohideo&submittedpassword=1234&submit=Logon"

Do you have any idea to fix ?

Thanks