Jump to content

Love2c0de

Members
  • Posts

    364
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Love2c0de

  1. To be quite honest, I thought it was the correct way to do so, keep 'required' data if you like in my users table and anything trivial such as a profile which isn't necessary I wanted to keep in a separate table.

     

    I'm guessing that normally you would keep all this info within the same table?

     

    Kind regards,

     

    L2c.

  2. Good evening all,

     

    I wanted to know something about users/profiles accounts.

     

    When a user registers should I be creating a default profile for them in my profiles table at the same that they register, maybe with null or empty fields? I hardcoded a dummy profile so I had something to work with and at the moment when they register, I only insert the data into the user table, and nothing into the profiles table. I am linking the two tables together via the username. With my dummy profile, I am at the point where I am now going to write the update query, but I figured if I don't create a default profile on registration, there will be no row to update as such.

     

    I thought if I insert the username into the profiles table at the same time as registering their details in my users table, when they come to 'editing' their profile and updating their profile, it will have a row to select.

     

    Is my train of thought correct or completely off mark? I hope I got my point across well enough.

     

    Kind regards,

     

    L2c.

  3. Good evening,

     

    I am working on user profiles and wonder whether or not I should bother validating the facebook, twitter and skype fields? For example, checking the twitter name starts with the @ symbol etc.

     

    I want to know what some of you would do, I don't really want to display an error for a bad social media name but I'm not sure if it standard practice to do so.

     

    Simple question really but it will probably lead into more questions before the night is gone!

     

    Thanks for your help and advice.

     

    Kind regards,

     

    L2c.

  4. More seriously, think SQL INJECTION. This is not the way to prevent it.

     

    Of course, had the topic continued I would told him about the dangers of putting data straight into a query but he didn't seem to reply so never got the chance.

     

    I believe he could be back when he has some unexpected results :happy-04:

     

    Regards,

     

    L2c.

  5. Try changing your code to this and see if it helps you:

     
    $db_usr= $_POST["userid"];
    $db_pswd= $_POST["password"];
    $con=mysql_connect("localhost",$db_user,$db_pass, $db_name);
    if(! $con)
    {
            die('Connection Failed'.mysql_error());
    }
    mysql_select_db("*****",$con);
    $sql=mysql_query("SELECT * FROM users WHERE userid={$db_usr} and password={$db_pswd}");
     
    $rows = mysql_num_rows($sql);
     
    if($rows == 1)
    {
         echo "Welcome back, ".$db_usr;
    }
    else
    {
        echo "You did not enter a correct username/password.";
    }
     
    

    You would also set a session if you are looking to create a user login system. Sessions retain their value when navigating through different pages on your website. A standard variable will not work as once the script ends, the standard variables' value is lost.

     

    Regards,

     

    L2c.

  6. This logic seems really off key to me.

     

    So, the values $_POST["userid"] and $_POST["password"] come from the form yes? Are they values which the user enters?

     

    With your mysql_connect() function, it takes only 3 parameter, but but you have specified 4 making me think you have got mixed up the with mysqli_ connect() extension which takes 4 - (host,user,password,db).

     

    mysql_connect() takes 3 - host, user, pass.

     

    You then connect to the database using mysql_select_db() - accepting 2 parameters the database name/variable and the link/connection variable.

     

    Having said that, you should really be using the mysqli_ extension as mysql standard declaration has been deprecated as of 5.5.0.

     

    Kind regards,

     

    L2c.

  7. Good evening,

     

    I am trying to create a user profile system on my website. I have the ability to register and login fine. I've hard coded a dummy profile into the profiles table.

     

    The way in which I am going to retrieve the profile data is by matching the users username in both tables.

     

    At the moment my query is returning all of the members in the user table and all of the profile information in the other table - profiles.

     

    This is my query:

     
    $stmt = $conn->prepare("SELECT * FROM users LEFT JOIN profiles ON users.? = profiles.username") or die("Error: ".mysqli_error($conn));
     
    

    Not sure if the way I am going about it is the correct way either so any advice and guidance is greatly received.

     

    Kind regards,

     

    L2c.

  8. What is the best format when storing addresses into a table?

     

    Should I split the address into separate columns like:

     

    house_name_or_number

    street_name

    city_or_town
    county

    post_code

     

    Or should I just store it into one field as a full string?

     

    Kind regards,

     

    L2c.

  9. If you are just searching for a matching postcode then the problem is simple. I would strip out any spaces from the code before storing as you are never sure if the user will always put a space in the middle. The first part of the postcode can be 2,3 or 4 chars but the second part is always 3.

     

     

    Good evening Barand,

     

    I'm not searching for a matching postcode as such, I need to return some results based on the distance, ordered nearest to farthest.

     

     

    If you want to use distance to find the nearest then, as Jessica said, you will need the geographic locations of CABs and you will have to get a file of postcodes with their locations. You can use lat and long positions but, if you have them, Ordinance Survey eastings and northings are easier (you can just apply Pythagoras) as the coordinates are in metres.

     

    So I need to have some sort of file/database which is holding the addresses and post codes of all the CAB's nationally. I'm not quote sure about the last sentence and will be researching all of this shortly but is there a way to integrate a database of addresses and postcodes of CAB's into something like the Google Maps API?

     

    Thanks for your input,

     

    Kind regards,

     

    L2c.

  10. Sorry I'm finding this difficult to explain.

     

    What I want is the user to enter their post code into an input, which will then display to them the nearest 5 citizens advice bureau addresses but ordered by distance from the users location.

     

    Let's say I'm in London and for example lets say there are 10 citizens advice bureaus in that city. I want my page to return the 5 nearest CAB's relevant to the users post code. Even if one of those 5 CAB's is not WITHIN London, it should display the 5 nearest ones.

     

    I need to determine what the distance is of each CAB depending on the users post code, then return to them 5 of the nearest CAB's

     

    Kind regards,

     

    L2c.

  11. Good evening,

     

    I want to have a page where users can enter their postcode to find their nearest Citizens Advice Bureau. This is throughout England (excluding Ireland, Scotland and Wales).

     

    My questions are:

     

    How can I compare the post code entered by the user to the post code of the exisiting Citizens Advice Bureau's?

     

    I know in PHP we can use a string function which compares the similarity between 2 strings but this clearly isn't going to suffice and work properly as you could have a CAB in London with post code SW1X 3RT (for example) and the users post code could be CM2 7ZN.

     

    My initial thoughts are to store the addresses and post codes of all the CAB's in a table but how do I compare those values and be accurate?

     

    The website company I work for have a similar functionality where we display certain things depending on user's post code so it is a fully post code driven site and I know our developer was coding a longitude and latitude script to determine this.

     

    Is that the only way to be accurate or would there be an easier solution or even a better one?

     

    Kind regards,

     

    L2c.

     

     

  12. First thing I see is change this:

     

    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");
    

     

    To this:

     

    mysql_connect($host, $username, $password)or die("cannot connect");
    mysql_select_db($db_name)or die("cannot select DB");
    

     

    because you are saving those values into variables, there is no need to put them within quotes. Run a print_r($_POST) statement at the top of the php script and what does it return?

     

    Kind regards,

     

    L2c.

  13. Find the table you want to put rounded borders on, give it a class of let's say 'rounded_borders'. Then in your CSS file put this:

     

    .rounded_borders
    {
        -moz-border-radius: 10px;
        border-radius: 10px;
    }
    

     

    Just checked in FF, IE10, GC, Opera, Safari and works in every one. You may have some issues with earlier versions of IE undoubtedly so you may want to go and explore that a little now you have something to work with.

     

    Hope this helps you.

     

    Kind regards,

     

    L2c.

  14. Just a long shot to be honest, but instead of floating your <div> elements left to get your desired result, you can set the #list_container to display any children <div>'s as inline-block elements. This means you will get exactly the same result as before but it could possibly sort your printing problem. I can't get to my printer right now (more like too lazy, it's in the other office) but give this code a try:

     

    CSS:

     

    #list_container
    {
        overflow:hidden;
    }
    
    #list_container > div
    {
        display: inline-block
    }
    
    #list_c1
    {
        width:200px;
    }
    
    #list_c2
    {
        width:200px;
    }
    
    #list_c3
    {
        width:200px;
    }
    

     

    I hope this helps you.

     

    Good luck.

     

    Kind regards,

     

    L2c.

  15. Update,

     

    Now I am getting the files to open up in the browsers ok only when I select 'Use built-in web server' though and my PHP code isn't executing.

     

    The url in the address bar now is: http://127.0.0.1:8020/Single-Fathers/index.php

     

    Anyone know what I am doing wrong? When I select the server which I set up it is still bringing up the error dialog with the message stated in my previous post.

     

    Kind regards,

     

    L2c.

  16. Good morning guys,

     

    Just wondering if you could possibly help me setup my WAMP server to work with Aptana 3?

     

    I have googled it and found a response from another blog type website and have tried what they said but to no avail.

     

    I have setup my workspace to be in C:\wamp\www.

     

    I have opened up my files in Aptana from the www\ folder, the same ones I had in my text editor.

     

    I went to Window -> Preferences and then Aptana Studio -> Web Servers and created a new web server.

     

    For the name I put 'Coder'.

     

    For the Base URL I put http://localhost

     

    For Document Root I put C:\wamp\www

     

    Not sure what I am doing wrong, when I try to run my index.php using the 'Run' button, it is opening up the file in FF and prompting for download.

     

    When I go to 'Run Configurations' and the 'Web Browser' node and click on the FF one, when I select 'Use selected server' and choose the one which I created nd try to run FF, it brings up an error saying: "'Launching Firefox - Internal Server' has encountered a problem. Generic server doesn't suport start". It is only when I choose 'Use built-in web server' in the configurations that it actually opens up firefox but then as stated it prompts for download.

     

    The link which is in the address bar when FF opens and prompts for download is this : file:///C:/wamp/www/Fathers/index.php

     

    Please help me, I really want to give IDE's a chance and I can't get this to work (first timer) :sweat:

     

    Thanks in advance,

     

    Regards,

     

    L2c.

     

     

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