可以使用 PHP 全局变量动态生成表单

发布于 2024-09-01 12:38:37 字数 805 浏览 11 评论 0原文

显然,我原来的帖子有些混乱,所以让我重新开始:

我本质上是在创建一个在线购物车,使经理能够为其员工注册我们提供的培训服务。我们对每位登记的员工收取 49 美元的服务费。然而,它与传统购物车的主要区别在于,我们必须收集有关参与该计划的“每位”员工的大量数据 - 并且该信息由雇主在注册/购买时提供。

作为经理,我输入我的个人信息,然后选择我想要注册的员工数量。目前,我的网站可容纳 7 名员工,但实际上需要容纳大约 30 名员工。我遇到的问题是缺乏动态能力和巨大的文件大小(特别是在验证方面)。

每个战士的信息都被传递并存储在会话超级全局变量中,例如:$_SESSION['F1Firstname'];和 $_SESSION['F1SSN3'];等等。我不想(也不会)使用 JavaScript 来“添加另一个登记者”按钮,因为这可以在客户端轻松关闭。

我的假设是这样的:

1)我必须能够动态地向每个新战士添加变量,以便它们可以存储在在线数据库中,然后传递到我们的测试中心 - 例如,雇员 1 的名字是 F1FirstName;员工 12 的出生日期是 F12DOB1,依此类推。

2) 每个员工的验证将基于每个单独的字段而相同(所有名字必须通过相同的测试)。所有电子邮件地址的验证必须通过相同的电子邮件验证测试等。如果我只是通过每个单独的记录构建此验证文件将会非常大。我想我需要以某种方式添加名字数组,但我不完全确定。

3)我需要它是可扩展的,从某种意义上说,我希望经理能够注册最多 100 名员工,他/她可以。

4) 正如我所提到的,这就像一个购物车,因此经理会立即登记所有员工,这样他们就可以在一次交易中为所有员工付款。

有人有什么想法吗?

Apparently there was confusion as to my original post so let me start over:

I am essentially creating an online shopping cart which gives a manager the ability to enroll his/her employees for training services which we provide. We charge $49 for the services for every employee enrolled. The primary difference between this and a traditional shopping cart however is that we must collect a solid amount of data about 'each' employee enrolled in the program - and this information is provided by the employer at the time of registration/purchase.

As a manager, I enter my personal information and then select how many employees I want to enroll. I currently have the site set up to handle 7 employees but actually need it to handle up to ~30. The issue I am having is the lack of dynamic ability and huge file sizes (especially in on the validation) I am running into.

Each fighter's information is passed and stored in session super globals such as: $_SESSION['F1Firstname']; and $_SESSION['F1SSN3']; and so on. I dont want to use javascript (and won't) to 'add another Enrollee' button because this can be turned off easily on the client side.

My assumptions are this:

1) I must be able to dynamically add variables to each new fighter so they may be stored in an online database and then passed along to our testing center - for example, emplotyee 1's name is F1FirstName; employee 12's Date of Birth is F12DOB1 and so on.

2) The validation for each employee will be the same based on each individual field (all first names must pass the same test). The validation for all email address must past the same email validation test and so on. If I simply build this by each individual record the validation file will be very large. I am thinking I need to add a Firstname array somehow but I'm not entirely sure.

3) I need this to be scalable that in the sense, I want a manager to enroll up to 100 employees, he/she can.

4) As I mentioned, this is like a shopping cart so a manager is enrolling all employees at once so they can pay for ALL of their employees in a single transaction.

Anybody got any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

装纯掩盖桑 2024-09-08 12:38:37

您可以根据 JavaScript 的需要生成其他字段。只需提供一个“添加拳击手”按钮,就不必有很多隐藏字段。

You can generate additional fields as needed by javascript. just provide a button 'add boxer' and there wouldn't have to be a lot of hidden fields.

陌路终见情 2024-09-08 12:38:37

如果您是“相当新的程序员”,最好的方法可能是只使用一个表格一次输入 1 个战斗机。更不用说这会更加用户友好。

If you're a "fairly new programmer" the best way would probably be to just have a form to input 1 fighter at a time. Not to mention this would be a lot more user friendly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文