使用html按钮从另一个文件中的类调用php函数
我用HTML设计了输入表单,并在最后按下了保存按钮。我希望SAVE按钮调用类中编写的php函数。类写入另一个文件中 文件使用html按钮从另一个文件中的类调用php函数,php,html,button,Php,Html,Button,我用HTML设计了输入表单,并在最后按下了保存按钮。我希望SAVE按钮调用类中编写的php函数。类写入另一个文件中 文件nabava_vnos.PHP开头的PHP代码,其中是HTML表单: <?php /** skripta za začetek seje in preverjanje prijavnih podatkov **/ session_start(); require_once(dirname(__FILE__)."/skripte/su.inc.php"); include
nabava_vnos.PHP
开头的PHP代码,其中是HTML表单:
<?php
/**
skripta za začetek seje in preverjanje prijavnih podatkov
**/
session_start();
require_once(dirname(__FILE__)."/skripte/su.inc.php");
include($path."/nabava.php");
include($path."/menu.php");
$SimpleUsers = new SimpleUsers();
$nabava = new nabava();
// This is a simple way of validating if a user is logged in or not.
// If the user is logged in, the value is (bool)true - otherwise (bool)false.
if( !$SimpleUsers->logged_in )
{
header("Location: index.php");
exit;
}
// If the user is logged in, we can safely proceed.
$userId = $_GET["userId"];
$user = $SimpleUsers->getSingleUser($userId);
if( !$user )
die("The user could not be found...");
$sifrant_oe = $nabava -> sifrant_oe();
阿蒂克利:
纳齐夫·阿蒂克拉科利切纳姆
普雷维兹尼克:
奥波姆巴:
Željen基准多波夫:
下面是我想调用的带有函数vnos_narocila的php类(文件nabava.php):
请帮助……你的意思是这样的:
require 'path_to_your_class';
if isset($_POST['submit']) {
$nabava = new nabava();
$vnosNarocila = $nabava->vnos_narocila();
}
您的
表单
标签在哪里?行动是什么?我需要表格标签吗?是的<代码>我现在添加了什么?放在哪里?
<?php
class nabava
{
private $mysqli, $stmt;
private $sessionName = "nabava";
public $logged_in = false;
public $userdata;
public function vnos_narocila($user, $hvrsta_narocila, $hlastna_nabava, $hos, $hsm_dn, $hoe, $hartikel1, $hkolicina_artikel1, $hem1, $hartikel2, $hkolicina_artikel2, $hem2, $hartikel3, $hkolicina_artikel3, $hem3, $hartikel4, $hkolicina_artikel4, $hem4, $hartikel5, $hkolicina_artikel5, $hem5, $hartikel6, $hkolicina_artikel6, $hem6, $hartikel7, $hkolicina_artikel7, $hem7, $hartikel8, $hkolicina_artikel8, $hem8, $hartikel9, $hkolicina_artikel9, $hem9, $hartikel10, $hkolicina_artikel10, $hem10, $hprevzemnik, $hopomba, $hzeljen_datum)
{
$zadnji_zapis = "SELECT * FROM nabava ORDER BY id_nabava DESC LIMIT 1"; //pridobitev zaporedne številke v letu
$leto = date('Y');
if ($zadnji_zapis[leto] == $leto )
$zap_st = $zadnji_zapis[zap_st]+1;
else $zap_st=1;
$narocilo = "N-".$zap_st."-".$hoe."/".$leto; //kreiranje številke naročila
$sql = "INSERT INTO nabava VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?, ?, ?)";
if( !$this->stmt = $this->mysqli->prepare($sql) )
throw new Exception("MySQL Prepare statement failed: ".$this->mysqli->error);
$this->stmt->bind_param("iiisssisiiii", $hvrsta_narocila, $hlastna_dobava, $hos, $hsm_dn, $hprevzemnik, $hopomba, $hzeljen_datum, $narocilo, $user, $zap_st, $hoe, $leto );
if( $this->stmt->execute() )
return $this->stmt->insert_id;
return false;
}
}
?>
require 'path_to_your_class';
if isset($_POST['submit']) {
$nabava = new nabava();
$vnosNarocila = $nabava->vnos_narocila();
}