Jump to content

INeedAGig

Members
  • Posts

    112
  • Joined

  • Last visited

    Never

Posts posted by INeedAGig

  1. Hey there guys, small problem here that I can't seem to figure out. I am in the process of programming a database with user-access control.  I have the log-in system working great, but the logout link, which is located next to the logged-in username seems to not be echoing correctly. It is loading the 'Logout' text in text-form only, not link-form....

     

    Any ideas on what may be causing this small glitch?? Thanks!! 

     

    I have attached relevant code for said part for reference.

     

    <img src="images/username.png" height="20" width="20"> <b>Welcome</b> <?php echo ("<font color=#9e0219>$username</font>");?>, <?php echo '<a href="logout.php">Logout</a>';?>
    

  2. Now, upon successful login, the page that is loaded, being 'main_interface.php'. This file BEGINS with the session control, that code being:

     

    <?php
    session_start();
    if (!isset($_SESSION['username']) || (trim($_SESSION['username'])=='')) 
    {
    header("location: login.html");
    exit();
    }
    

  3. HTML for the form:

     

    <form id="login" name="login" method="post" action="login.php">
    <p><img src="images/locked.png" height="20" width="20"> Restricted Access - Authentication Required</p>
    <label>Username <img src="images/username.png" height="20" width="20">
    <span class="small"><i>Enter a valid username</i></span>
    </label>
    <input type="text" name="username" id="username">
    <label>Password <img src="images/password.png" height="20" width="20">
    <span class="small"><i>Password is case sensitive</i></span>
    </label>
    <input type="password" name="password" id="password">
    <button type="submit">Login</button>
    <div class="spacer"></div>
    </form>
    

  4. Hey there guys, I have been trying to resolve this myself the past hour or so and I can't seem to figure it out. I am in the middle of programming a contacts database, with a login system. Now, the register.php file I created to create users for the database works, but the following code is from my login.php file.

     

    When I am on the page in my browser and I type in a registered username and password combination it simply just reloads the login.php file, with blank form fields, as if you had just loaded the page. I am not quite sure what is causing this.

     

    Here is the code from my login.php file:

     

    <?php
    //Database Information
    $dbhost = "removed_for_this_post"; //Host Name
    $dbname = "removed_for_this_post"; //Database Name
    $dbuser = "removed_for_this_post"; //Database Username
    $dbpass = "removed_for_this_post"; //Database Password
    
    //Connect To Database
    mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
    mysql_select_db($dbname) or die(mysql_error());
    
    session_start();
    
    $username = $_POST['username'];
    $password = md5($_POST['password']);
    
    $query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
    $result = mysql_query($query);
    
    if (mysql_num_rows($result) != 1) {
    $error = "Bad Login";
    include "login.html";
    } else {
    $_SESSION['username'] = "$username";
    include "main_interface.php";
    }
    
    ?>
    

     

    Thanks for your help in advance!! :)

  5. Hey guys, I am adding to my current php form processor and I need it to be able to support image uploads, that also show up as an attachment in the email with the rest of the form data. The only part I am having problems with is getting the image to work as an attachment in the email, at the moment, it is not showing up at all in the email but it is successful at showing up on the web server (which I have it doing for storage reasons). I have attached the code involved for the image processing portion, an also a snippet of code showing how the emails are sent.

     

    This code is for the image attachment processing

     

    <?php
    //Get the uploaded file information
    $name_of_uploaded_file =
    basename($_FILES['uploaded_file']['name']);
    
    //Get the file extension of the file
    $type_of_uploaded_file =
        substr($name_of_uploaded_file,
        strrpos($name_of_uploaded_file, '.') + 1);
    $size_of_uploaded_file =
        $_FILES["uploaded_file"]["size"]/1024;//size in KBs
    
    //Settings
    $max_allowed_file_size = 150; // size in KB
    $allowed_extensions = array("jpg", "jpeg", "gif", "bmp", "png");
    
    //Validations
    if($size_of_uploaded_file > $max_allowed_file_size )
    {
      $errors .= "\n File size too large! Max file size alowed is $max_allowed_file_size";
    }
    
    //------ Validate the file extension -----
    $allowed_ext = false;
    for($i=0; $i<sizeof($allowed_extensions); $i++)
    {
      if(strcasecmp($allowed_extensions[$i],$type_of_uploaded_file) == 0)
      {
        $allowed_ext = true;
      }
    }
    if(!$allowed_ext)
    {
      $errors .= "\n The uploaded file is not supported file type. ".
      " Only the following file types are supported: ".implode(',',$allowed_extensions);
    }
    
    //Copy the temp. uploaded file to server
    $path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;
    $tmp_path = $_FILES["uploaded_file"]["tmp_name"];
    if(is_uploaded_file($tmp_path))
    {
      if(!copy($tmp_path,$path_of_uploaded_file))
      {
        $errors .= '\n Error while copying the uploaded file';
      }
    }
    ?>
    

     

    This is the header setup for sending the email, which for some reason I think i am missing something here, causing the image to not show up in the email.

     

    $headers = "From: edited_out_for_this_post@edited_out_for_this_post.com\r\n";
    $headers .= "Reply-To: no-reply@edited_out_for_this_post.com\r\n";
    $headers .= "Return-Path: no-reply@edited_out_for_this_post.com\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    

     

    Thanks for your help in advance!

  6. I'm not saying it's an HTML issue, I wasn't sure where to post this...maybe as an admin you can point me in the right direction? Also, it wouldn't be a bad a idea to have a 'General Coding Help' forum for people to post in, for times where we might not know the actual language/function that is needed. 

     

    Now, I haven't really dealt with in browser PDF activity, but I do have experience with forms and email forms (PHP). I'm trying to figure out where I would start with something like this.  I've researched this on Google myself trying to find anything about it, and there really isn't much relevant to what I am trying to do. Help is appreciated, not a negative sounding reply. ;)  Thanks.

  7. I am having a slight display problem with my Javascript/CSS carousel. It is a carousel of just images that are all spaced 30px apart from eachother. Now, Google Chrome is the only browser that seems to be overlapping all of the pictures on top of each other, what might be causing this?

     

    Thanks!

  8. I'm a little confused as to how to approach this. I am needing to allow a user of my website to fill out a PDF and have the contents automatically emailed to me after the user submits the filled out pdf, which I want to be all done in the browser, as far as the user filling out the PDF, kind of like the way a normal form works.

  9. I already have the file created, with the 0, which has now updated itself to '1' but no further, I can't CHMOD, constant '504 command not implemented for that parameter' error in FileZilla....I know that's what is holding it up...just not sure how to get the permissions set now.

  10. Alrighty, I fixed that line of code, which is now:

     

    $var = fopen("$myfile", "r+") or exit ("Unable to open file!");
    

     

    But I am receiving this error on the page:

     

    Warning: fopen(counter/hits.txt) [function.fopen]: failed to open stream: Permission denied

     

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