Copy link to clipboard
Copied
Hi guys, I'm using dreamweaver's PHP functions as not too experienced with the code. I've setup a MySQL database with 2 tables 'company' and 'register'. Companies login with a username and password and get authenticated by the 'company' table. This contains 3 fields, userName, Password and CompanyName. Once logged in, people fill out a form to register a personal account. The info from the form inserts into the register table and this is working ok. Problem is, on submit I need to grab their companyName from the 'company' table and post it to 'companyName' in the register table but don't know how. I've already got the company name displaying on the page using <?php echo $row_Recordset1['companyName']; ?> so it's there for the taking! This is what i'm using to insert the form data to the register table, but how do I grab from another table? Thanks
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO register (fullName, telephone, email1, email2, newsletter, reminder, password1, password2, comments, agree) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['fullname'], "text"),
GetSQLValueString($_POST['telephone'], "text"),
GetSQLValueString($_POST['email1'], "text"),
GetSQLValueString($_POST['email2'], "text"),
GetSQLValueString($_POST['newsletter'], "text"),
GetSQLValueString($_POST['reminder'], "text"),
GetSQLValueString($_POST['password1'], "text"),
GetSQLValueString($_POST['password2'], "text"),
GetSQLValueString($_POST['comments'], "text"),
GetSQLValueString(isset($_POST['agree']) ? "true" : "", "defined","'Y'","'N'"));
Copy link to clipboard
Copied
>but how do I grab from another table
You can easily insert data from one table into another, but there is no need to in this case. You already have that data avaiable from the recordset. Just use that recordset variable in your insert statement.
Copy link to clipboard
Copied
Just use that recordset variable in your insert statement.
That's what's confusing me, I don't know much PHP so i'm using the DW data objects. The code I posted is inserting into 'register' from form fields on the page. If I choose 'insert record' from the DW menu, it only lets me link the form fields with DB fields, not the dynamic text. thanks
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more