johnnh Posted May 4, 2007 Share Posted May 4, 2007 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 More sharing options...
1042 Posted May 4, 2007 Share Posted May 4, 2007 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; } } Link to comment https://forums.phpfreaks.com/topic/50033-help-with-password-login/#findComment-245709 Share on other sites More sharing options...
johnnh Posted May 5, 2007 Author Share Posted May 5, 2007 Thanks for reply But this doesnt solve the problem? Im still gettin a parse error. ? j Link to comment https://forums.phpfreaks.com/topic/50033-help-with-password-login/#findComment-246031 Share on other sites More sharing options...
Lumio Posted May 5, 2007 Share Posted May 5, 2007 You can not use the header-function when there is something before. Make it like that: <?php //some code header('header...'); ?> rest of html and php Link to comment https://forums.phpfreaks.com/topic/50033-help-with-password-login/#findComment-246033 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.