PDA

View Full Version : intergrating with php to insert fields into textboxes


jeevan1984
11-23-2005, 08:26 PM
I am pretty much an ameture at flash and php. based on the save movie position tutorial that some of you have may have seen, i have created 2 php files that gets data from the mysql files and inserts it into a flash file, well, trying to anyway

its a very simple file

i am basically asking to spot the errors if you can see any

the file runs of my localhost, im not sure how to load the actual files up so ive just copied the code from each file onto here.

the mysql file contains just 2 fields
- id (unique id)
- telno

here is the first php file


CODE

?


$DBhost = "localhost";
$DBuser = "";
$DBpass = "";
$DBName = "insurance";
$table = "contact";

?>


then the login php

require 'include2.php';

// Connects to the database.
mysql_connect($DBhost,$DBuser,$DBpass);
mysql_select_db("$DBName");

// The SQL query
$query = "SELECT * FROM $table WHERE id = '$id'";
$result = mysql_query($query);

/* This just gets the number of rows in the Query - It's just a check to see if the Name exists - If not it prints out an error statement. */
$numR = mysql_num_rows($result);

// If the number of rows is not equal to one then it prints out an error statement - Name not in Database.

if ($numR == 1) {
print "Status=Success Login Complete&CheckLog=1";
}
else {
print "Status=Failure - Your name was not found - Please register";
}

?>

then finally the register(loadining) php file


CODE

<?php
// The registration script adds a record to the SQL database with the user's Name. That's about it.

// This first line of Code is to load your database variables.
require 'include2.php';

// Connects to the Database.
mysql_connect($DBhost,$DBuser,$DBpass);
@mysql_select_db("$DBName");

//selects "id" from the database

$result = mysql_query("SELECT * FROM $contact WHERE id = '$id'");

//This sets the variables from the Database
$id = mysql_result($result,0,"id");
$telno = mysql_result($result,0,"telno");

/* This next bit prints out the value's of the Comment and the positions of the three objects whose properties you want to save. This is the line that Flash will read into the movie. */

print "$telno";

?>


then the flash file

frame 1


CODE
stop ();


frame 2


CODE
// if checklog (from login3.php) has a value, go to frame 6
//otherwise go to frame 2

//just to make sure login.php was succesful at loading
if (CheckLog ne "") {
gotoAndPlay (6);
} else {
gotoAndPlay (2);
}


frame 4


CODE

loadvairablesnum ("register2.php?id="+id, 0);
gotoandplay (6);


frame 6


CODE

//if there is a value for id, enter it into texttel.text

if (id ne "") {
texttel.text = ("telno");
}
else{
gotoandplay (1);
}


and the button of the movie


CODE
on (release) {

if (Name ne "") {
gotoAndPlay(2);
Status = "Beginning Login Process.. Please Hold";
//The next line calls the Login.php script. And returns the results from it to the movie.
loadVariablesNum ("Login2.php?id="+id+"&R="+random(999), "0");
}
else {
Status = "Please enter a User Name";
}

}


thanks