Reputation: 221
Hello i have an html form and i'm posting data but i'm unable to get the posted data on a php page (same page) can you please help me. thanks in advance
<div class="left">
<form name="form_signin" method="post" onsubmit="return signinValid();" >
<table>
<tr>
<td>
Email :
</td>
<td>
<input type="text" id="email" length ="40">
</td>
</tr>
<tr>
<td>
Mot de Passe :
</td>
<td>
<input type="password" id ="pass" length ="40">
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" value="Connexion" length ="40">
</td>
</tr>
</table>
</form>
<?php
include 'includes.php';
include DB_CONNECT_FILE;
//session_start();
print_r($_POST); // prints an empty array even if fields are filled
$smart->assign('tpl_file',TEMPLATES_DIR.'signin.html');
$smart->display(TEMPLATES_DIR."with_right.html");
include DB_DISCONNECT_FILE;
?>
Upvotes: 0
Views: 170
Reputation: 8289
Your form element needs to have an action attribute defined, even if the form is just reposting to the same page. According to the W3C spec, it is a required attribute:
http://www.w3.org/TR/html401/interact/forms.html#h-17.3
I'm suprised this line isn't throwing an error:
$smart->assign('tpl_file',TEMPLATES_DIR.'signin.html');
As far as I'm aware, you can only use comma seperation when echo-ing.
UPDATE Can't believe I missed it the first time around! You'll need to add the name attribute to the input elements. They can be the same as the id attribute for the element in question:
<input type="text" id="email" name="email" size="40">
Also, there is no such attribute as length. There is maxlength, but I suspect you mean to use size.
Upvotes: 1
Reputation: 5348
Check what is doing that javascript. It could be returning false (in this way you are preventing the post) or stopping the propagation. At first try deleting that onsubmit.
Upvotes: 0