javascript - Undefined index with php and ajax -
why var in php undefined? code html
<table> <tbody id="table"> <tr> <th colspan="2">signup</th> </tr> <tr> <td>firstname:</td><td>lastname:</td> </tr> <tr> <td><i class="fa fa-user"></i><input type='text' maxlength="25"autocomplete="off" size="20" id="fn"></td><td><i class="fa fa-user"></i><input type='text' maxlength="25"autocomplete="off"size="20" id="ln"></td> </tr> <tr> <td colspan="2"><div>djname(username): <i class="fa fa-headphones"></i><input type='text' maxlength="25"autocomplete="off"size="20" id="us"></div></td> </tr> <tr> <td>password:</td><td>repassword:</td> </tr> <tr> <td><i class="fa fa-unlock-alt"></i><input type='password' maxlength="25"autocomplete="off"size="20" id="pass"></td><td><i class="fa fa-unlock-alt"></i><input type='password' maxlength="25"autocomplete="off"size="20" id="repass"></td> </tr> <tr> <td>email:</td><td>reemail:</td> </tr> <tr> <td><i class="fa fa-envelope"></i><input type='text' maxlength="30"autocomplete="off"size="20"id="email"></td><td><i class="fa fa-envelope"></i><input type='text' maxlength="30"autocomplete="off"size="20" id="reemai"></td> </tr> <tr> <td colspan="2"><button type="submit" id="button">signup</button> </td> </tr> </tbody> </table>
code javascript:
var httpajax; if(window.xmlhttprequest)httpajax= new xmlhttprequest(); else httpajax= new activexobject('microsoft.xmlhttp'); httpajax.onreadystatechange= function(){ if(httpajax.readystate== 4 && httpajax.status== 200){ } }; httpajax.open('post','signup.php',true); httpajax.setrequestheader("content-type","application/x-www-form-urlencoded"); httpajax.send('firstname='+document.getelementbyid('fn').value+ '&lastname='+document.getelementbyid('ln').value+ '&djname='+document.getelementbyid('us').value+ '&password='+document.getelementbyid('pass').value+ '&repassword='+document.getelementbyid('repass').value+ '&email='+document.getelementbyid('email').value+ '&reemail='+document.getelementbyid('reemail').value);
code php:
<?php $name=$_post['firstname'];$lastname=$_post['lastname'];$username=$_post['djname'];$password= $_post['password'];$repassword=$_post['repassword'];$email= $_post['email'];$remail= $_post['remail']; echo $name,$lastname,$username,$password,$repassword,$email,$remail; ?>
it's strange. console not give me error , have been staying here long time. explanation of error.thanks
notice: undefined index: firstname in c:\xampp\htdocs\sito\signup.php on line 2
notice: undefined index: lastname in c:\xampp\htdocs\sito\signup.php on line 2
notice: undefined index: djname in c:\xampp\htdocs\sito\signup.php on line 2
notice: undefined index: password in c:\xampp\htdocs\sito\signup.php on line 2
notice: undefined index: repassword in c:\xampp\htdocs\sito\signup.php on line 2
notice: undefined index: email in c:\xampp\htdocs\sito\signup.php on line 2
notice: undefined index: remail in c:\xampp\htdocs\sito\signup.php on line 2
the content type sending contains typo. should application/x-www-form-urlencoded, not application/x-www-orm-urlencoded.
Comments
Post a Comment