GNU nano 2.2.6 File: /var/www/TestPage.php
//I'm not sure about the part in Orange.
<?php
echo "Displaying Database<div>";
$con=mysqli_connect("127.0.0.1","phil","Pass","Website");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM Films");
while($row = mysqli_fetch_array($result))
{
echo $row['id'] . " " . $row['name'];
echo "<br>";
}
mysqli_close($con);
?>
<html>
<body BGCOLOR="000000" TEXT="0800FF">
<center><h1>TestPage</h1></center>
<img src="Images\Banner.png" width="1700" height="200">
<form action="insert.php" method="post">
Nom: <input type="text" name="name">
<input type="submit">
</form>
<form action="remove.php" method="post">
Id: <input type="text" name="id">
<input type="submit">
</form>
</center>
</body>
</html>
//I'm not sure about the part in Orange.
<?php
echo "Displaying Database<div>";
$con=mysqli_connect("127.0.0.1","phil","Pass","Website");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM Films");
while($row = mysqli_fetch_array($result))
{
echo $row['id'] . " " . $row['name'];
echo "<br>";
}
mysqli_close($con);
?>
<html>
<body BGCOLOR="000000" TEXT="0800FF">
<center><h1>TestPage</h1></center>
<img src="Images\Banner.png" width="1700" height="200">
<form action="insert.php" method="post">
Nom: <input type="text" name="name">
<input type="submit">
</form>
<form action="remove.php" method="post">
Id: <input type="text" name="id">
<input type="submit">
</form>
</center>
</body>
</html>
I tried a billion ways to do this(at this point the code is a hellpit and needs hardcore fixing), plz send me working code lmao =(.
<?php
//mysql_query($sql);
$con=mysqli_connect("127.0.0.1","phil","pass","Website");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$id_m = $_POST['id'];
$sql = "DELETE Films ".
"WHERE id = $id_m" ;
//$sql = "DELETE FROM Films WHERE id=$id_m";
mysql_query($sql,$con);
mysqli_close($con);
header( 'Location: TestPage.php' ) ;
?>
And this is the working code to add stuff to the table...if u wanna take a look.
<?php
//echo $_POST['id'];
$con=mysqli_connect("127.0.0.1","phil","pass","Website");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO Films (name)
VALUES
('$_POST[name]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
header( 'Location: TestPage.php' ) ;
?>
Comment