Jump to content

White_Lily

Members
  • Posts

    531
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by White_Lily

  1. Okay  - so i wrote a login script for a site im building. However when you click "Login" it goes to a login-handler.php script, which seems to only show an Internal Server Error 500. I've tried using error checking to no success as it still shows the same screen.

     

     

    I'm hoping someone will be able to tell me what I have done wrong.

     

     

    <?php
    
    
    $log_user = $_POST["username"];
    $log_pass = $_POST["password"];
    
    if(empty($log_user))
    {
    	die "Please go back and fill in your username.";
    }
    
    if(empty($log_pass))
    {
    	die "Please go back and fill in your password.";
    }
    
    $sql = "SELECT * FROM users";
    $res = mysql_query($sql);
    
    if(mysql_num_rows($res) != 0)
    {
    	$row = mysql_fetch_assoc($res);
    
    	$dbuser = $row["username"];
    	$dbpass = $row["password"];
    
    	if($log_user != $dbuser)
    	{
    		echo 'Please go back and enter a valid username.';
    	}
    
    	if($log_pass != $dbpass)
    	{
    		echo 'Please go back and enter a valid password.';
    	}
    
    	if($log_user == $dbuser && $log_pass == $dbpass)
    	{
    		session_register($log_user);
    		session_register($log_pass);
    		header("Location: index.php");
    	}
    
    }
    else
    {
    	echo "There doesn't appear to be any users in the database.";
    }
    
    
    ?>
    

  2. Ive read through this quite carefully and like you i can't see any errors, however the script does look a bit awkward in the way of proccessing - maybe try searching the web for a pre-built secure login system, and just modify it to suit your needs - you may even find videos on youtube which you can follow, this way your learning to.

  3. Anyway - a few errors poped up with your code, however i fixed them and my problem is solved.

     

     

    Fixed code:

     

     

    <?php
    
    
       include "sql/conf.php";
       include "sql/connect.php";
    
    
       $page = "Welcome";
    
    
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[url=http://www.w3.org/TR/html4/loose.dtd]http://www.w3.org/TR/html4/loose.dtd[/url]">
    <html>
       <head>
          <title><?php echo $GLOBALS["siteName"]." - ".$page; ?></title>
          <link rel="stylesheet" type="text/css" href="css/main.css">
          <link rel="stylesheet" type="text/css" href="css/sub-css.css">
          <link rel="stylesheet" type="text/css" href="css/tags.css">
       </head>
       <body>
          <div class="wrapper">
             <div class="header">
                <div class="head">
                   <img src="images/logo.png" alt="HTML Bites Logo">
                <>
             <>
             <div class="sub-wrapper">
                <div class="navigation">
                   <div id="navigation">
                      <a href="index.php">Home</a>
                      <a href="#">News</a>
                      <a href="#">Gallery</a>
                      <a href="#">Tutorials</a>
                      <a href="#">Downloads</a>
                      <a href="#">Contact</a>
                   <>
                <>
                <div class="content">
                   <div class="center-column">                  
                      <?php
                         
                         //$page_name = $_POST['page'];
    
    
                         $sql = 'SELECT * FROM pages WHERE title = "'.$page.'"';
                         $res = mysql_query($sql);
    
    
                         while($row = mysql_fetch_assoc($res))
                         {
                            $title = $row["title"];
                            $content = $row["content"];
                            echo "<h1>".$title."</h1>";
                            echo $content;
                         }
                            
                         if(mysql_num_rows($res) == 0)
                         {
                            echo "<h1>Oops...</h1>";
                            echo "<p>This page doesn't appear to exsist!</p>";
                            echo "<p>Use the 'Quick Contact' box to contact the webmaster and tell them about the page you are requesting.</p>";
                         }
                         
                      ?>

  4. Hi,

     

     

    I made a bit of code that would get a pages title and content from a database, however every time i put this bit of code into the file, and upload that file, i then get an "Internal Server Error (500)". Whereas if i take the code out, and uplaod the file - the webpage is fine?

     

     

    
    					<?php
    
    						$sql = "SELECT * FROM pages WHERE title = '$page'";
    						$res = mysql_query($sql);
    
    						if($row = mysql_fetch_assoc($res)
    						{
    							$title = $row["title"];
    							$content = $row["content"];
    
    							echo "<h1>".$title."</h1>";
    							echo $content;
    						}
    						else
    						{
    							echo "<h1>Oops...</h1>";
    							echo "<p>This page doesn't appear to exsist!</p>";
    							echo "<p>Use the 'Quick Contact' box to contact the webmaster and tell them about the page you are requesting.</p>";
    						}
    
    					?>
    

     

     

    Not sure where ive gone wrong.

  5. Hi, I have written some code that once the form prior to this page is completed and submitted should update the users password.

     

    Problem im having is that everytime i submit the form for testing, it comes up with a blank page, which is usually a Internal Server Error 500.

     

    However i cannot see where the code has gone wrong! Any help appreciated.

     

                                <div class="form_form">
                                    <?php
                                    
                                        $old    =    $_POST["old"];
                                        $new    =    $_POST["new"];
                                        $conf    =    $_POST["conf"];
                                        
                                        if(!$user && !$pass)
                                        {
                                            echo "You need to be logged in to change any passwords.";
                                        }
                                        else
                                        {
                                            $sql = "SELECT * FROM members WHERE password = '$old'";
                                            $res = mysql_query($sql);
                                            
                                            $row    =    mysql_fetch_assoc($res);
                                            
                                            if($old != $row["password"])
                                            {
                                                die "The old password you provided did not match the database, go back and try again.";
                                            }
                                            
                                            if($new != $conf)
                                            {
                                                die "The new passwords you entered did not match each other, go back and try again.";
                                            }
                                            
                                            $sql = "UPDATE members SET password = '$new' WHERE password = '$old'";
                                            $res = mysql_query($sql);
                                            
                                            if(!$res)
                                            {
                                                die "Could not update your password. Error: ".mysql_error();
                                            }
                                            else
                                            {
                                                echo "You password has been changed.";
                                            }
                                        }
                                        
                                    ?>
                                </div>
    

     

  6. I can only answer the first question, i dont tend to work with mobile devices so the second question is out of my knowledge.

     

     

    as for the width of the sub-nav, try setting the width to something like 100-150px, and set the height to auto, this way anything longer should just stretch to two lines.

  7. I dont like using blob. i tend to use VARCHAR in phpMyAdmin, and it works fine for me. and from what my code is the php is pretty simple, although im using the code for avatars and banner images.

     

     

    What i do is store the image in a directory, and the filename in the database.

×
×
  • 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.