$_POST is always blank!

Not sure why this is happening in this instance.
But everytime I submit a form <form method=‘post’ action=‘thepathtothefile’>

if I do print_r($_POST); on the receiving page, it is always displayed as:
Array( )

Not sure why this isnt showing, it works in other places in the code.

Any quick suggestions?

Who kicks ass? Yes, that’s right, SJH does!

THANKS :slight_smile: Talk about an oversight, perhaps it’s time for the optician?

as I said, it’s standard.

<form method=‘post’ action=‘addnew.php’>
Name: <input type=‘text name=‘name’ value=’’ /><br/>
Surname: <input type=‘text name=‘surname’ value=’’ /><br/>
Email: <input type=‘text name=‘email’ value=’’ /><br/>
Password: <input type=‘text name=‘password’ value=’’ /><br/>
Role: <input type=‘text name=‘role’ value=’’ /><br/>
Company: <input type=‘text name=‘company’ value=’’ /><br/>
<input type=‘submit’ value=‘Add’ />



addnew.php prints “Array( )”

Not without some code :slight_smile:

I did, but it was wrapped in a PHP string, so couldnt see anything other than grey :stuck_out_tongue:

You might settle for colored syntax highlighting :wink:

You’ve missed the closing quotes from the end of the type attribute in your form fields so the name of the field is never being sent :slight_smile:

As a suggestion, if you’re going to generate your HTML on the fly, it may not be a bad idea to create PHP objects to wrap your HTML Generation. I’ve done this in my code base, and it removes issues like that completely (since I only need to be sure that I’ve created syntactically correct HTML once, instead of on every line).

So, for instance, this is an example Form created during a test page that I’ve written to test Session Access Methods:

$form = new HTMLForm();
$form->setCustomStyle(array("action", "method"), array("?", "post"));
$form->addElement("This is a test textbox: ");
$form->addElement(new FormInput(array("type", "name", "value"), array("text", "test", "cars")));
$form->addElement("<br />\
$form->addElement(new FormInput(array("type", "value"), array("submit", "Submit")));

And the output looks like this:

<form action = "?" method = "post">
This is a test textbox: <input type = "text" name = "test" value = "cars">
<br />
<input type = "submit" value = "Submit">

I know how I did it in a way which works for me, though I can’t promise that it will be the best choice for you. There will likely be purists (especially MVC purists) who criticize it for a lack of separation, and they’ve got valid points, but part of the beauty of PHP is its flexibility with things like this.

Hope that gives you an idea, if you have any questions, I’d be happy to help. I know it’s definitely saved me a TON of debugging time. :slight_smile:

Using a PHP Class to process the form/html would be easier in the event of multiple instances and keeping consistancy with styling etc as you could create a “site palette” to just reuse without near duplicate code.