
December 31st, 2012, 08:44 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 3
Time spent in forums: 24 m 41 sec
Reputation 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.
|