Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,151,098 members, 7,811,087 topics. Date: Saturday, 27 April 2024 at 11:03 PM

Php Error. .Pls Help! - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Php Error. .Pls Help! (1722 Views)

I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help / 500 Internal Server Error >>>>>> Pls Explain / I Keep Getting This Error::pls Help ::parse Error: Syntax Error, Unexpected '.', (2) (3) (4)

(1) (Reply) (Go Down)

Php Error. .Pls Help! by Dawgzfada(m): 7:07pm On Jun 15, 2011
<?php

      error_reporting(0);
      session_start();
      include_once ', /db.php';

      /***************************** Step 2 ****************************/
      if(isset($_REQUEST['admsubmit']))
      {
         
          $result=executeQuery("select * from adminlogin where admname='".htmlspecialchars($_REQUEST['name'],ENT_QUOTES)."' and admpassword='".md5(htmlspecialchars($_REQUEST['password'],ENT_QUOTES))."'"wink;
        if(mysql_num_rows($result)>0)
          {
             
              $r=mysql_fetch_array($result);
              if(strcmp($r['admpassword'],md5(htmlspecialchars($_REQUEST['password'],ENT_QUOTES)))==0)
              {
                  $_SESSION['admname']=htmlspecialchars_decode($r['admname'],ENT_QUOTES);
                  unset($_GLOBALS['message']);
                  header('Location: admwelcome.php');
              }else
          {
             $_GLOBALS['message']="Check Your user name and Password.";
                 
          }

          }
          else
          {
              $_GLOBALS['message']="Check Your user name and Password.";
             
          }
          closedb();
      }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>Administrator Login</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="stylesheet" type="text/css" href=", /oes.css"/>
  </head>
  <body>
<!--
*********************** Step 1 ****************************
-->
      <?php
     
        if(isset($_GLOBALS['message']))
        {
         echo "<div class=\"message\">".$_GLOBALS['message']."</div>";
        }
      ?>
      <div id="container">
                <div class="header">
               
            </div>
      <div class="menubar">
        &nbsp;
      </div>
      <div class="page">
              <form id="indexform" action="index.php" method="post">
              <table cellpadding="30" cellspacing="10">
              <tr>
                  <td>Admin Name</td>
                  <td><input type="text" name="name" value="" size="16" /></td>

              </tr>
              <tr>
                  <td> Password</td>
                  <td><input type="password" name="password" value="" size="16" /></td>
              </tr>

              <tr>
                  <td colspan="2">
                      <input type="submit" value="Log In" name="admsubmit" class="subbtn" />
                  </td><td></td>
              </tr>
            </table>

        </form>

      </div>

      </div>
  </body>
</html>


Ordinarily, if username and pwd is correct, i should be taken to admwelcome.php, but it doesn't work that way. I still remain on the same index.php. Please is there anything i'm doing wrong.

Thanks y'all.
Re: Php Error. .Pls Help! by bakenda(m): 9:06am On Jun 16, 2011
Did you md5 hash the admin password before saving it to database?

Comment out the
 error_reporting(0);
line and

let's see if any error message comes up.
Re: Php Error. .Pls Help! by Dawgzfada(m): 9:16am On Jun 16, 2011
bakenda:

Did you md5 hash the admin password before saving it to database?

Comment out the
 error_reporting(0);
line and

let's see if any error message comes up.

Yes. I md5 hash the admin password.

I just commented out
error_reporting(0);
but no difference still.

What i noticed is once i try logging in with an invalid admin name/pwd, the error msg comes up but once i enter the right usrname/pwd, nothing happens. .but the session seems to have been set 'cos if i go to admwelcome.php manually, i'll be able to access it.

I've been on this for hours. .Any help pls?
Re: Php Error. .Pls Help! by bakenda(m): 9:20am On Jun 16, 2011
Do you have an htacces file in your script folder
that handles redirection?

Just let me know if you have an htaccess file, and if yes
paste the content here.

Cheers, help is on the way. smiley smiley smiley
Re: Php Error. .Pls Help! by Dawgzfada(m): 9:35am On Jun 16, 2011
bakenda:

Do you have an htacces file in your script folder
that handles redirection?

Just let me know if you have an htaccess file, and if yes
paste the content here.

Cheers, help is on the way. smiley smiley smiley

No. sad

Thanks for the inspiration.
Re: Php Error. .Pls Help! by bakenda(m): 1:50pm On Jun 16, 2011
Open a new notepad page, drop the following line in it:

PHP_FLAG output_buffering on



save the page as .htaccess

choose the "All Files" option when saving

drop the file in the folder containing your scripts.

Let's hear how it goes.
Re: Php Error. .Pls Help! by Dawgzfada(m): 3:08pm On Jun 16, 2011
Thanks so much bro. It worked like a charm. Thanks bruv. I rily appreciate.



Re: Php Error. .Pls Help! by Dawgzfada(m): 3:09pm On Jun 16, 2011
Time to learn: What does the .htaccess hack PHP_FLAG output_buffering on do?
Re: Php Error. .Pls Help! by bakenda(m): 3:47pm On Jun 16, 2011
The pleasure is mine.

Very Short Explanation:

Actually, if you want to use the header() function to redirect
to another page, then it has to come before anything else
in the script, that is, you should not send the header after
the page output has started(logical enough), but we can't
avoid that most of the time as evidenced in your script.

Without output buffering (the default), your HTML is sent
to the browser in pieces as PHP processes through your script.
With output buffering=on, your HTML is stored in a variable and
sent to the browser as one piece at the end of your script.

The instruction in the htaccess file is just to instruct Apache
to turn output buffering on, hope you get the idea.
Re: Php Error. .Pls Help! by Nobody: 8:06pm On Jun 16, 2011
I am still not sure of where the problem is exactly, if it is from the server, or from the codes. . .
Re: Php Error. .Pls Help! by bakenda(m): 6:50am On Jun 17, 2011
The problem is from the codes but it has a server solution,
and it has been solved, the software that interprets the
codes is on the server. The problem could also have been
solved by modifying the codes - if he could find a way to
place the header directive before any output is sent
Re: Php Error. .Pls Help! by Nobody: 5:16pm On Jun 17, 2011
@poster, i seem to have figured out the problem - send the files to my email - zip 'em first
Re: Php Error. .Pls Help! by DualCore1: 5:19pm On Jun 17, 2011
*dhtml:

@poster, i seem to have figured out the problem - send the files to my email - zip 'em first
You and seun dey smoke the same pot this evening? 


=========
on a side note, ob_start() at the beginning of your php and ob_flush() at the end of it should also fix this.
Re: Php Error. .Pls Help! by bakenda(m): 6:59pm On Jun 17, 2011
Dual Core:


=========
on a side note, ob_start() at the beginning of your php and ob_flush() at the end of it should also fix this.

Yeah, that will also get the problem solved for the particular
script
the ob there stands for output buffering.

The advantage of using an htaccess file is that it takes
care of all files with that issue instead of inserting ob_start()
and ob_flush() in every script.
Re: Php Error. .Pls Help! by DualCore1: 8:28pm On Jun 17, 2011
Nice idea.
This should be a "default" for my .htacces cuz ob_start ad flush are as good as regulars on my scripts.
Re: Php Error. .Pls Help! by Nobody: 10:05pm On Jun 17, 2011
Dual Core:

You and seun dey smoke the same pot this evening? 


=========
on a side note, ob_start() at the beginning of your php and ob_flush() at the end of it should also fix this.
No weed man, ganja. . .

Well, lets hope your solutions work, i have a different and shorter approach than all that. . .but am not posting
it yet, let us hope the above work - it should on a normal day sha
Re: Php Error. .Pls Help! by DualCore1: 11:35pm On Jun 17, 2011
I will believe you if you tell me you have a shorter way of <?php echo "babe" ?> cool

(1) (Reply)

What Experience Did You Have With Eyowo / Why Alexa Ranking Is Useless / Ranking Algorithm Isn’t Perfect / Beware Of Goldxservice.net || Fraud Company || $425 Usd Scam!

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 35
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.