3我有一个我在我的网站上开发的表格但是没有joomla结构.在表单上,我试图调用活动用户数据,如下所示:
$user = JFactory::getUser();
echo "<p>Your name is {$user->name}, your email is {$user->email}, and your username is {$user->username}</p>";
Run Code Online (Sandbox Code Playgroud)
但我得到:致命错误:第38行/home5/onlinepc/public_html/action/subs/custompcorder.php中找不到类'JFactory'
custompcorder.php是我创建的表单的名称,第38行是$ user = JFactory :: getUser(); 我的客人我必须在我的档案中加入一些东西吗?
我需要从下面的表单中将条目插入到mysql表中.1-form包含许多行.2条目在行中不总是连续的(意味着第1行可以为空而下一行不是)3 - 包含条目的所有行都应保存在db表中.
我想INSERT INTO oz2ts_custompc_details(part_id,数量,价格)
这是我的报名表(custompc_form2.php)
<!DOCTYPE html>
<html>
<body>
<form action="../subs/custompcorder2.php/" method="post" id="form">
<p><input id="name" name="part_id[]"/>
<input type="text" id="quantity" name="quantity[]"/>
<input id="name-data" type="text" name="price[]"/></p>
<p><input id="name" name="part_id[]"/>
<input type="text" id="quantity" name="quantity[]"/>
<input id="name-data" type="text" name="price[]"/></p>
<p><input id="name" name="part_id[]"/>
<input type="text" id="quantity" name="quantity[]"/>
<input id="name-data" type="text" name="price[]"/></p>
<p><input id="name" name="part_id[]"/>
<input type="text" id="quantity" name="quantity[]"/>
<input id="name-data" type="text" name="price[]"/></p>
<input id="submit" type="submit" value="Submit Order" name="submission"/>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我想出的但仍然没有工作.以下是它如何工作的摘要:||第1行到第4行有数据>所有4个都保存了|| 第1行为空,第2行到第3行包含数据>仅第2行和第3行保存而不是第4行|| 第2行只有所有其他数据为空的数据>数据未保存|| 第2行和第3行有数据>仅保存第2行
<?php
include '../db/connect.php';
foreach (array('part_id', 'quantity', 'price') as …Run Code Online (Sandbox Code Playgroud)