gpt4 book ai didi

javascript - 如何在codeigniter中提交表单后获取成功消息

转载 作者:行者123 更新时间:2023-12-02 23:17:08 25 4
gpt4 key购买 nike

我正在 codeigniter 中做一个表单。这是我的代码:

<?php echo form_open_multipart(''); ?>
<div class="input-group">
<input maxlength="30" type="text" name="name" placeholder="Name" class="form-control" required>
</div>
<div class="input-group">
<select onchange="getcountrycode(this)" name="country" placeholder="Country" class="form-control" required>
<option value="">Select Country</option>
<option value="+971" class="form-control">UAE</option>
<option value="+968" class="form-control">OMAN</option>
<option value="+974" class="form-control">QATAR</option>
<option value="+91" class="form-control">IND</option>
<option value="+966" class="form-control">KSA</option>
</select>
</div>
<div class="input-group" style="display: flex;">
<input style="width: 27%;text-align: left;padding: 15px;border-right: 0px;" type="tel" id="code" name="code"
placeholder="*Code" class="form-control" readonly>
<input style="width: 63%;" type="tel" name="mobile" placeholder="Mobile No" class="form-control" required>
</div>
<div class="input-group">
<input type="email" name="email" placeholder="Email" class="form-control" required>
</div>
<div class="input-group">
<select name="myselect" placeholder="Type" class="form-control" required>
<option value="">Select Type</option>
<option value="Product" class="form-control">Product</option>
<option value="Order" class="form-control">Order</option>
<option value="Complaint" class="form-control">Complaint</option>
<option value="Return" class="form-control">Return</option>
<option value="Refund" class="form-control">Refund</option>
<option value="Other" class="form-control">Other</option>
</select>
</div>
<div class="input-group">
<textarea maxlength="200" name="message" placeholder="Message" class="form-control" required></textarea>
</div>
<center><button type="submit" id="submit" name="submit" value="Submit" class="submit">Submit</button></center>
<br>
</form>

我希望在提交包含所有必填字段的表单后弹出一条成功消息。有人可以帮我吗?

最佳答案

试试这个

Controller 文件

成功消息:

$this->session->set_flashdata("success","New User Register Successfull..!");
redirect("user","refresh");

错误信息

$this->session->set_flashdata('error','Rong User Details');
redirect("user","refresh");

查看文件

<?php 
if ($this->session->flashdata('success')) { ?>
<div class="alert alert-success">
<?php echo $this->session->flashdata('success'); ?>
</div>
<?php
?>
<?php
if ($this->session->flashdata('error')) { ?>
<div class="alert alert-danger">
<?php echo $this->session->flashdata('error'); ?>
</div>
<?php
?>

关于javascript - 如何在codeigniter中提交表单后获取成功消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57123715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com