我有一个表单,并且在该表单中有一个名为offer的文本区域,我需要在单击提交按钮时通过post方法将输入到该文本区域的文本传递到其他页面。但是当它检索时,输入的文本就像这样显示:
I%20would%20like%20to%20buy%20your%20vehicle
如何删除?
reviewOfferView.php
<form name="myform5" action="<?php echo base_url().'submitOfferCtrl/submitOffer/'. $email.'/'. $offer.'/'. $msg .'/'. $id;?>" method="POST">
submitOfferCtrl.php
public function submitOffer($selleremail,$offer,$msg,$id)
{
$this->main_model->submitOffer($selleremail,$offer,$msg,$id);
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'dtt@gmail.com',
'smtp_pass' => 'dtt1',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email',$config);
$this->email->set_newline("\r\n");
$this->email->from('dtt@gmail.com');
$this->email->to($selleremail);
$this->data['posts']=$this->main_model->getOffer($selleremail,$id);
$this->email->subject('A offer has been made on your advertisement');
$body=$this->load->view('pages/sendOffer',$this->data,TRUE);
$this->email->message($body);
if($this->email->send())
{
$this->session->set_flashdata('success_msg', 'Your message has been sent succesfully through email');
redirect("http://localhost/ci/ads_ctrl");
}
else
{
$this->session->set_flashdata('success_msg', 'Check your internet connection and try again');
redirect("http://localhost/ci/ads_ctrl");
}
}
}
答案 0 :(得分:1)
你应该urldecode()
?
这不是通过$_POST
提交的。它是通过$_GET
提交的。如果你可以从URL中提取它,那么它不是$_POST
提交的,无论你在表单声明中说了什么。
<?php echo form_open(); ?>
会打开您的表单。还有一个贴心的标签。您可以在括号中包含参数以调用正确的方法。
然后,您需要清理/准备表单输入以进行电子邮件提交。你不会从URL获得它。
修改强>
如果你坚持走这条路,
$msg = urldecode($msg);
应删除%20个空格。
编辑#2
我不推荐这个。
答案 1 :(得分:0)
您可以使用class Employee:
'Common base class for all employees'
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount += 1
def displayCount(self):
print ("Total Employee %d" % Employee.empCount)
def displayEmployee(self):
print ("Name : ", self.name, ", Salary: ", self.salary)
def changeSalary(self, n):
self.salary = n;
class ChiefEmployee(Employee):
def __init__(self, name, salary):
Employee.__init__(self, name, salary)
emp3 = ChiefEmployee("Gerhardt", 500)
print(emp3.displayEmployee())
这样的功能:
str_replace()
我希望它有所帮助!
答案 2 :(得分:0)
您可以使用urlencode()和urldecode()方法。如下所示
reviewOfferView.php
<form name="myform5" action="<?php echo base_url().'submitOfferCtrl/submitOffer/'. $email.'/'. urlencode($offer).'/'. urlencode($msg) .'/'. $id;?>" method="POST">
submitOfferCtrl.php
public function submitOffer($selleremail,$offer,$msg,$id)
{
$offer = urldecode($offer);
$msg = urldecode($msg);
// your code here..
}