Jump to content

Help with password login


johnnh

Recommended Posts

Howdy

Can someone advise please i need to provide a password that when verified(not sure if this codes correct) connects to a dbase and preloads a form ready to ammend /submit new data. I am having trouble with the format and have unexpected parse error which i am unable to resolve.

Would be gratefull if someone could take a look at the code and tell me where im going wrong as im currently banging my head against a brick wall.

 

Many thanks

 

<html>

<head>

<title>Update</title>

</head>

<body>

 

 

<?php if (!isset($PHP_AUTH_USER)) {

 

// If empty, send header causing dialog box to appear

 

header('WWW-Authenticate: Basic realm="My Private Stuff"');

header('HTTP/1.0 401 Unauthorized');

echo 'Authorization Required.';

exit;

 

} else if (isset($PHP_AUTH_USER)) {

 

if (($PHP_AUTH_USER != "a") || ($PHP_AUTH_PW != "ab")) {

 

header('WWW-Authenticate: Basic realm="My Private Stuff"');

header('HTTP/1.0 401 Unauthorized');

echo 'Authorization Required.';

exit;

 

} else {

 

 

//connect to database

$id = $HTTP_GET_VARS['pageid'];

 

$dbConnection = @mysql_connect ("localhost","root","") OR die ('could not connect:'.mysql_error());

 

// select the database to use

 

@mysql_select_db ("accessibility") OR die ('could not connect to database:'.mysql_error());

 

 

$result = mysql_query ("SELECT * FROM content WHERE id ='$id'") or die ("could not retrieve");

 

$update = mysql_query ("UPDATE content SET WHERE id ='$id'") or die ("could not retrieve");

 

$database_record = mysql_fetch_row($result);

//$database_record = $database_record[1]; // mysql_fetch_row returns an array. we only want the content so we just set it excluseively.

 

}?>

 

<form action="updated.php" method="post">

<?php echo $id;?></br>

content a<input type="text" name="contenta" value="<?php Echo $database_record [1]; ?>"><br>

CONTENT B<input type="text" name="contentb" value="<?php Echo $database_record [2]; ?>"><br>

Image a<input type="text" name="iamgea" value="<?php Echo $database_record [3]; ?>"><br>

Image b<input type="text" name="imageb" value="<?php Echo $database_record [4]; ?>"><br>

script<input type="text" name="script" value="<?php Echo $database_record [5]; ?>"><br>

Links<input type="text" name="links" value="<?php Echo $database_record [6]; ?>"><br>

<input type="submit" value="Update">

</form>

 

</body>

</html>

 

 

help

 

Link to comment
https://forums.phpfreaks.com/topic/50033-help-with-password-login/
Share on other sites

You are not closing you else if statement on line 17, you need to close it on line 26 see below, i added for you at the end;

 

else if (isset($PHP_AUTH_USER)) {

if (($PHP_AUTH_USER != "a") || ($PHP_AUTH_PW != "ab")) {

header('WWW-Authenticate: Basic realm="My Private Stuff"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;

} }

 

 

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.