Çevirdim derken, uygulamayı tamamen mi php ye çevirdiniz yoksa php ile python scripti tetiklenecek şekilde mi değiştirdiniz?
Eski kod
import tkinter as tk
def calculate_run(slope, height):
return height / slope
def on_button_click():
slope = float(slope_entry.get())
height = float(height_entry.get())
run = calculate_run(slope, height)
run_label.config(text=f"Rampa Uzunluğu: {run:.2f} cm")
root = tk.Tk()
root.title("ramp slope calculator")
slope_label = tk.Label(root, text="Ramp Slope")
slope_label.pack()
slope_entry = tk.Entry(root)
slope_entry.pack()
height_label = tk.Label(root, text="Rampa height (cm)")
height_label.pack()
height_entry = tk.Entry(root)
height_entry.pack()
calculate_button = tk.Button(root, text="Calculate", command=on_button_click)
calculate_button.pack()
run_label = tk.Label(root, text="")
run_label.pack()
root.mainloop()
Yeni kod
form action="" method="post">
Ramp Slope: <input type="text" name="slope"><br>
Ramp Height (cm): <input type="text" name="height"><br>
<input type="submit" name="submit" value="Calculate">
</form>
<?php
if (isset($_POST['submit'])) {
$slope = floatval($_POST['slope']);
$height = floatval($_POST['height']);
$run = $height / $slope;
echo "Rampa Uzunluğu: " . number_format($run, 2) . " cm";
}
?>