Hey guys i was wondering if you could help me with an issue. I know how to post text fields, usernames and passwords.But I want to have a dropdown that gets tables from my database and i want to select the table and then post to the database which table is assigned to the ftp I’m using. This script is for adding FTP details to MySQL database so each user can get their own CSV files. This is what i have so far:
<label>Folder Structure :</label>
<input type="text" name="location" id="location" required="required" placeholder="folder1/folder2"/><br /><br />
<label>Host Name :</label>
<input type="text" name="hostname" id="hostname" required="required" placeholder="test@ftp.edu"/><br /><br />
<label>Username :</label>
<input type="text" name="username" id="username" required="required" placeholder="John123"/><br/><br />
<label>Password :</label>
<input type="text" name="password" id="password" required="required" placeholder="Password"/><br/><br />
<label>CSV Filename :</label>
<input type="text" name="filename" id="filename" required="required" placeholder="test.csv"/><br/><br />
<label>RTU :</label>
<?php
$result = $con->query("SHOW TABLES WHERE `Tables_in_irrigation` NOT LIKE 'user%' and `Tables_in_irrigation` NOT LIKE 'company%' and `Tables_in_irrigation` NOT LIKE 'roles%' and `Tables_in_irrigation` NOT LIKE 'ftp%'and `Tables_in_irrigation` NOT LIKE 'RTU_LINK%'");
if($result->num_rows > 0) {
echo '<select name="rtu" id="rtu">';
while($row = $result->fetch_array(MYSQLI_NUM)) {
echo '<option>' . $row[0] . '</option>';
}
echo '</select>';
}
?>
$sql = "INSERT INTO ftp (location,hostname,username,password,filename,rtu)
VALUES ('".$_POST["location"]."','".$_POST["hostname"]."','".$_POST["username"]."','".$_POST["filename"]."','".$_POST["rtu"]."')";
if ($conn->query($sql) === TRUE) {
echo "<script type= 'text/javascript'>alert('New record created successfully');</script>";
} else {
echo "<script type= 'text/javascript'>alert('Error: " . $sql . "<br>" . $conn->error."');</script>";
}
$conn->close();
}
?>