dongyongmin5711
2018-02-24 10:51
采纳率: 100%
浏览 36
已采纳

PHP:在OOP上使用POST并存储在MySql中

Ok im kinda new to using oop on php, So this what im tryna do. getting the value of the textbox putting them in an array then storing them in database but the problem is it doesnt store the data

<?php
require ('employmentfunc.php');
?>
<html>
<head>
</head>
<body>
<?php 
$arr = array(isset ($_POST['company']), isset ($_POST['position']));

if (isset($_POST['ok']))
{
    $a = new empfunc();
    $a->SaveA($arr);
}
?>
<form name="emp" action="employmentform.php" method="POST">

<TD><input type="text" name="company">
<td><input type="text" name="position">
<input type="submit" class="button1" name="ok">
</form>
</body>
</html>



<?php
class empfunc{

function saveA($array){
    $sqlconnect = mysqli_connect("localhost", "root","","employment");
    $sqlquery = "INSERT INTO info(`Company`, `Position`) VALUES ('$array[0]', '$array[1]')";
    mysqli_query ($sqlconnect, $sqlquery);
}
}
?>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题