Reputation: 8366
I am new to PHP. I'd like to get a variable that is in another document in order to insert a value into a table. So, I have this code: insert.php:
$inputField = $_POST['inputField'];
$inputField2 = $_POST['inputField2'];
$Allowed_traffic = $_POST['Allowed_traffic'];
$Frequency = $_POST['Frequency'];
$sql="INSERT INTO users_fup (fup_id, user_id, ModemSn, start_date, end_date, allowed_traffic, realized_traffic, frequency, nextreset, whichdb) VALUES ('NULL','','', '".$inputField."', '".$inputField2."', '".$Allowed_traffic."', '', '".$Frequency."', '', '')";
I want to take ModemSn from another file which contains:
$ffup = mysql_query("SELECT * FROM users_fup WHERE ModemSn = '".$row['ModemSn']."' AND start_date < '$oraoggi' AND end_date > '$oraoggi' ");
.
.
echo "<td>".$row['ModemSn']."</td><td>".$percent_traffic."</td><td>linksetfup</td><td></td></tr>";
The files are not in the same folder.
Upvotes: 0
Views: 72
Reputation: 33993
You can't directly.
What you probably want to do is put the value from $row['ModemSn']
in an hidden input field in the form that you are using in the above code.
Then you can get the values you want by running the query in the second code block with the $_POST['ModemSn']
value (from your hidden input field)
Also, how you are building your queries is very vulnerable for SQL Injection (that is what @Quentin means)
Upvotes: 1