#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    Php files to mysql


    New Members

    4 posts
    0 warning points


    Posted 15 December 2012 - 02:57 PM

    Hello All, I am new to this forum and new to PHP. In Flash i am building a login system for my website. To do this I need to create a php file for Flash to connect to the mysql database. Now, i am a complete novice to php and i am struggling to find the right code for my php file.
    Mysql database is called "example" and my table is called users.

    My php file is below: Can you please take a close look. I know it's probably full of errors but i have only just started learning php. Can you please highlight the errors for me and if i am missing something can you please tell me.
    PHP Code:
    <?php 
    //Declare variables
    //connect
    $id $_POST['id'];
    $email $_Post['email'];
    $username $_POST['username']; 
    $password $_POST['password'];
    $age $_POST['age'];
    $country $_POST['location'];
    $gender $_POST['gender'];
     
    //connects to database
    $link mysql_connect("localhost""example""password") or die (mysql_error());
    mysql_select_db("example_users") or die(mysql_error());
     
     
    //collects data from table
    $data mysql_query("SELECT * FROM users WHERE col_username='$username' AND col_password='$password'");
    if (
    mysql_num_rows($data) == 0) {
      echo 
    "systemResult=The login detail dont much our records";
    }
    else {
      while (
    $row mysql_fetch_assoc($data)) {
        
    $userbio $row["name"];
        echo 
    "systemResult=$userbio";
      }
    }

    // escape username and password for use in SQL
     
    $user mysql_real_escape_string($user);
     
    $pwd mysql_real_escape_string($pwd);
     
    $sql "SELECT * FROM users WHERE
     user='" 
    $user "' AND password='" $pwd "'"
     
    // more code
     
    mysql_close($con);
    }
    ?>
    Last edited by E-Oreo; December 31st, 2012 at 11:03 AM.
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,143
    Rep Power
    9398
    I, for one, love it when people copy a post from another forum (including some non-post content) and paste it somewhere else. I love it even more when the original thread looks like it's been answered already. Even more when that all happened a couple weeks earlier.

    Comments on this post

    • ptr2void agrees : SEO Bot or Clueless Copy/Paster looking for someone to just fix his code?

IMN logo majestic logo threadwatch logo seochat tools logo