Welcome Guest, Not a member yet? Register   Sign In
[Help] $post data didn't post anything.. Did I do something wrong ? Please Advice.
#1

[eluser]Willy Wijaya[/eluser]
Hi, I try to make a simple code to retrieve $_POST data.. Here is my code..
controller/blog.php
Code:
class Blog extends Controller {
    function Blog() {
        parent::Controller();
        //$this->load->scaffolding('');
        $this->load->helper('url');
        $this->load->helper('form');        
    }
    function index() {
        $this->load->view('blog_view');
    }
    function kirimdata() {
        $data['name'] = $this->input->post('name');
        $data['valid'] = $this->input->post('valid');    
        $this->load->view('blog_kirimdata', $data);
    }
}

view/blog_view.php
Code:
<body>
<h1> My First Heading </h1>
<hr />
&lt;?= form_open('blog/kirimdata/'); ?&gt;
&lt;input name="name" type="text" size="30" maxlength="30" /&gt;
&lt;input name="valid" type="hidden" value="yes" /&gt;
&lt;input name="Submit" type="submit" value="Submit" /&gt;
&lt;/form&gt;
&lt;/body&gt;

view/blog_kirimdata.php
Code:
&lt;body&gt;
<h1>This is The Result from blog_view.php</h1>
<hr />
&lt;?= $name; ?&gt;
&lt;?= $valid; ?&gt;
&lt;/body&gt;

Please your advices, guys.
Why its always return false ?
#2

[eluser]tomcode[/eluser]
Code:
&lt;input name="name" type="text" size="30" maxlength="30" /&gt;

requires a value attribute.
#3

[eluser]Willy Wijaya[/eluser]
Hi,
I have changed it to
&lt;input name="name" type="text" size="30" maxlength="30" value="" /&gt;

But, it still doesnt show anything except blank..
Thank for quick reply
#4

[eluser]tomcode[/eluser]
It works on my machine using Firefox, even without the value attribute. Of course, I need to enter a value for the input name field to have a returned value showing up. The 'yes' from the hidden field shows up.
#5

[eluser]Willy Wijaya[/eluser]
Smile it doesnt work on my machine.. I use both IE and Mozilla..
I'm using PHP 5.3, apache 2.2..
is it any related issues with php.ini setting ?
I set register_globals=off
I think it should be fine.. I'm getting confused.. because I cannot develop any apps if I cannot get $_POST data.. Sad
#6

[eluser]Willy Wijaya[/eluser]
Here is my php.ini setting:
magic_quotes_gpc = Off
post_max_size = 10240M
memory_limit = 1024M
max_input_time = 600
max_execution_time = 600
upload_max_filesize = 10240M
register_globals = off

I have no idea whats going on.. Please others contribution..
#7

[eluser]tomcode[/eluser]
register_globals are off on my machine, too.

Well, first You should have valid HTML pages, Your views are not.
Then put
Code:
print_r($_POST);

or (nicer)
Code:
echo '<pre>' .print_r($_POST, true) .'</pre>';

in Your Controller constructor. Then You see when and whether $_POST is filled.

If $_POST is not set, then I'd test it by writing a form without CodeIgniter.
#8

[eluser]Willy Wijaya[/eluser]
post.php
Code:
&lt;?php
        $name = $_POST['name'];
        $valid = $_POST['valid'];
?&gt;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
<h1> Test $_POST data </h1>
    &lt;?php
        echo $name.'<br/>';
        echo $valid.'<br/>';
    ?&gt;
<hr/>
&lt;form action="#" method="post" name="form"&gt;
&lt;input name="name" type="text" size="30" maxlength="30" value="" /&gt;
&lt;input name="valid" type="hidden" value="yes" /&gt;
&lt;input name="Submit" type="submit" value="Submit" /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

what's going on with my apache server ?
I cannot cache my post data..
#9

[eluser]Willy Wijaya[/eluser]
Hi,

I have reinstalled my apache server, and it works again with $_POST data..
But, when I run some script which is written in CI 1.7.1, I always get $_POST data empty and it cannot $_POST anything. It breaks my apache server. I have reinstalled my apache server twice Sad ..
FYI, I'm using windows XP, apache 2.2, PHP 5.2.9, MySQL 5, and I run in on my localhost machine..

But, when I uploaded those scripts into live environment in Linux Centos 5.3, everything work fine.
Is there anyone facing the same issue with me ?
Please your information.
#10

[eluser]Willy Wijaya[/eluser]
Hi, I found the answer for this prob.
It because you set post_max_size in php.ini larger than memory_limit and others restriction. Please refer to http://php.net/manual/en/ini.core.php

Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size . When an integer is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used. If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. &lt;form action="edit.php?processed=1"&gt;, and then checking if $_GET['processed'] is set.

Quote:Note: PHP allows shortcuts for bit values, including K (kilo), M (mega) and G (giga). PHP will do the conversions automatically if you use any of these. Be careful not to exceed the 32 bit signed integer limit (if you're using 32bit versions) as it will cause your script to fail.




Theme © iAndrew 2016 - Forum software by © MyBB