Grow your CSS skills. Land your dream job.

PHP Login Systems and Shop help

  • # January 4, 2010 at 3:52 pm

    Well first off I like to say right off the bat that I think I bit off more than I can chew but It’s my first official client and I’m not going turn that down, however he wants a login system and a shop. I have never come across either of these before but I gave it a go, I followed a few tutorials and managed to make a rather simple but working php/MySQL login system that only shows certain pages once logged in. My first problem lies here, I showed the client and he was impressed but the register system only has three parts: username, password and email. He wants me to add in a few more variables like first name, last name and date of birth, he also wants it so you have to retype the password. My problem is that once I edit the table and the php and test it out it tells me there’s an error and I can’t work out what’s wrong.

    The tutorial I followed: http://net.tutsplus.com/tutorials/php/u … -with-php/

    My login system: http://cyanoxide.co.uk/Stranded/login.html

    Code for the login page:

    Code:
    < ?php include "base.php"; ?>
    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



    < ?php
    if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username']))
    {
    ?>

    Member Area

    Thanks for logging in! You are < ?=$_SESSION['Username']?> and your email address is < ?=$_SESSION['EmailAddress']?>.

    < ?php
    }
    elseif(!empty($_POST['username']) && !empty($_POST['password']))
    {
    $username = mysql_real_escape_string($_POST['username']);
    $password = md5(mysql_real_escape_string($_POST['password']));

    $checklogin = mysql_query("SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'");

    if(mysql_num_rows($checklogin) == 1)
    {
    $row = mysql_fetch_array($checklogin);
    $email = $row['EmailAddress'];

    $_SESSION['Username'] = $username;
    $_SESSION['EmailAddress'] = $email;
    $_SESSION['LoggedIn'] = 1;

    echo "

    Success“;
    echo “

    We are now redirecting you to the member area.

    “;
    echo ““;
    }
    else
    {
    echo “

    Error

    “;
    echo “

    Sorry, your account could not be found. Please click here to try again.

    “;
    }
    }
    else
    {
    ?>

    Member Login

    Thanks for visiting! Please either login below, or click here to register.



    < ?php
    }
    ?>

    Code for the Register system:

    Code:
    < ?php include "base.php"; ?>
    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



    < ?php
    if(!empty($_POST['username']) && !empty($_POST['password']))
    {
    $username = mysql_real_escape_string($_POST['username']);
    $password = md5(mysql_real_escape_string($_POST['password']));
    $first = mysql_real_escape_string($_POST['first']);
    $last = mysql_real_escape_string($_POST['last']);
    $dob = mysql_real_escape_string($_POST['dob']);
    $email = mysql_real_escape_string($_POST['email']);

    $checkusername = mysql_query("SELECT * FROM users WHERE Username = '".$username."'");

    if(mysql_num_rows($checkusername) == 1)
    {
    echo "

    Error“;
    echo “

    Sorry, that username is taken. Please go back and try again.

    “;
    }
    else
    {
    $registerquery = mysql_query(“INSERT INTO users (Username, Password, EmailAddress) VALUES(‘”.$username.”‘, ‘”.$password.”‘, ‘”.$email.”‘)”);
    if($registerquery)
    {
    echo “

    Success

    “;
    echo “

    Your account was successfully created. Please click here to login.

    “;
    }
    else
    {
    echo “

    Error

    “;
    echo “

    Sorry, your registration failed. Please go back and try again.

    “;
    }
    }
    }
    else
    {
    ?>

    Register

    Please enter your details below to register.




    < ?php
    }
    ?>

    My second problem is that he wants me to add a shop to the site so the users can purchase tickets and merchandise in advance, but I can’t find any tutorial or help on this, I want the information used to log in to stick when you buy something so it doesn’t have to retype it.

    I know this is a lot to ask and I’m not asking for someone to bail me out of this situation but a push in the right direction will be greatly appreciated.

    # January 9, 2010 at 12:59 pm

    Okay, it’s almost been a week since I posted this, I have solved the first issue with the form but I’m still clueless about the shop. It needs to all happen on board the website and not redirect to paypal or anything like that, he supplied me with a link to a page which has the kind of system he was looking for but I don’t know how to make it, nor do I know what to search for to find a tutorial on this.

    Any help would be greatly appreciated, I want to get this project done and dusted.

    link to his reference: http://www.carnageuk.com/order_now.php

    # September 23, 2011 at 4:15 pm

    Hi — any chance at this late date to get you to tell us exactly how you solved the first issue?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".