我正在尝试获取视图输入框中的项目。 我正在使用:
$email = $this->input->post('email', true);
为了获得输入框内的内容。但它没有获得任何东西。
该功能运行于:
<?php $function = array('auth/start', $price);?>
<form action="<?php echo base_url($function);?>"method="post">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_xZrfWwuBmwBzUBynB96OgZhU"
data-amount=""
data-name="Turbine Engine"
data-description="Individual Membership"
data-image="/128x128.png">
</script>
</form>
我有以下内容:
控制器:
function start()
{
$username = 'a';
$price = '100';
$password = 'password';
$email = $this->input->post('email');
$end = date('Y-m-d', strtotime('+1 years'));
$additional_data = array(
'first_name' => $this->input->post('first_name'),
'middle_initial' => $this->input->post('middle_initial'),
'last_name' => $this->input->post('last_name'),
'company' => $this->input->post('company'),
'phone' => $this->input->post('phone'),
'biography' => $this->input->post('biography'),
'address' => $this->input->post('address'),
'city' => $this->input->post('city'),
'state' => $this->input->post('state'),
'zip' => $this->input->post('zip'),
'position' => $this->input->post('position'),
'country' => $this->input->post('country'),
'website' => $this->input->post('website'),
'listing' => 'N',
'type' => 'I',
'registration_end' => $end,
);
//load payment library
$this->load->library( 'stripe' );
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
try {
//attempt to charge user
$this->stripe->charge_card( intval($price), $token, "Individual Membership" );
}
catch(Stripe_CardError $e)
{
// The card has been declined
}
//If passed then add a new user
//add the user
$this->ion_auth->register($username, $password, $email, $additional_data);
$this->session->set_flashdata('message', 'Payment Successful');
//TEST
//load parameters
$type = 'new account';
$date = date('Y-m-d');
date_default_timezone_set('Australia/Melbourne');
$time = date('h:i:s a', time());
//load the controller for adding activity
$this->load->library('../controllers/activity');
$this->activity->insert($email, $type, $date, $time);
//send to login
//$this->showView('login');
redirect("auth", 'refresh');
}
查看:
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-default">
<div class="panel-body">
<!--Put Labels in order-->
<style>
label
{
display: inline-block;
width: 120px;
}
</style>
<h4>Individual Payment Page</h4>
<b>Make sure your email is correct</b>
<hr>
<p>
<?php echo form_label("Email:");?> <br />
<?php echo form_input(array('id' => 'email', 'name'=>'email','value'=>$email,'size'=>'30',
'readonly'=>'true'));?>
</p>
<!-- Make Hidden Labels to Pass the username and password-->
<p>
<?php echo form_input('username',$username);?>
<?php echo form_input('password',$password);?>
<?php echo form_input('first_name', $first_name);?>
<?php echo form_input('middle_initial',$middle_initial);?>
<?php echo form_input('last_name', $last_name);?>
<?php echo form_input('company', $company);?>
<?php echo form_input('phone', $phone);?>
<?php echo form_input('biography',$biography);?>
<?php echo form_input('address', $address);?>
<?php echo form_input('city', $city);?>
<?php echo form_input('state', $state);?>
<?php echo form_input('zip', $zip);?>
<?php echo form_input('position', $position);?>
<?php echo form_input('country', $country);?>
<?php echo form_input('website', $website);?>
</p>
<br>
<p>
<b>Click Below for Payment</b> <br>
</p>
<p><h4>1.) Regular Individual </h4><br>
<?php echo form_label("Price:");?> <br />
<?php echo form_input(array('name'=>'price','value'=>$price,'size'=>'30',
'readonly'=>'true'));?>
</p>
<?php $function = array('auth/start', $price);?>
<form action="<?php echo base_url($function);?>"method="post">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_xZrfWwuBmwBzUBynB96OgZhU"
data-amount=""
data-name="Turbine Engine"
data-description="Individual Membership"
data-image="/128x128.png">
</script>
</form>
<p><h4>2.) Regular Individual with Listing Enabled</h4><br>
<?php echo form_label("Price:");?> <br />
<?php echo form_input(array('name'=>'price_listing','value'=>$total,'size'=>'30',
'readonly'=>'true'));?>
</p>
<?php $function2 = array('auth/start_listing', $username, $password, $email, $first_name, $middle_initial, $last_name, $company, $phone, urldecode($address), $city, $state, $zip, urldecode($biography), $position, urldecode($country), urldecode($website), $total);?>
<form action="<?php echo base_url($function2);?>"method="post">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_xZrfWwuBmwBzUBynB96OgZhU"
data-amount=""
data-name="Turbine Engine"
data-description="Individual Membership"
data-image="/128x128.png">
</script>
</form>
</div>
</div>
</div>
</div>
</div>
谢谢。我感谢任何帮助。
答案 0 :(得分:0)
在您看来,你有这个:
//...
<?php echo form_input(array('id' => 'email', name'=>'email','value'=>$email,'size'=>'30', 'readonly'=>'true'));?>
//...
<form action="<?php echo base_url($function);?>"method="post">
// ...
</form>
但是您在此输入之前没有打开表单,因此您的输入未提交,因此请首先打开表单:
echo form_open('url here');
echo form_input(array('id' => 'email', 'name'=>'email','value'=>$email,'size'=>'30', 'readonly'=>'true'));
//other inputs...
form_close();
form_open
打开/创建开始表单标记,form_close
创建结束表单标记。您还可以使用<form>
和</form>
,然后将所有输入放在表单中:
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button" ...></script>
详细了解Form Helper。
答案 1 :(得分:0)
输入表单中没有任何form_open()和form_close()。请更新您的代码,这将解决您的问题。
答案 2 :(得分:0)
要发布文字字段,您需要将其括在表单标记
中<input type="text" name="email" value="" />
<form action="someurl" method="post">
</form>
在这种情况下,什么都不会发布到服务器 如果您需要发布文本字段,则需要在表单标记内移动
<form action="someurl" method="post">
<input type="text" name="email" value="" />
</form>
或
form_open('someurl');
<?php echo form_label("Email:");?> <br />
<?php echo form_input(array('id' => 'email', name'=>'email','value'=>$email,'size'=>'30', 'readonly'=>'true'));?>
form_close();
确保所有文本字段都包含在表单
中