registration - Errors while registrate as user --php -
i going create registration in php shows me following errors:
string(59) "insert users (username,email,password)values('','','')" duplicate entry '' key 'email'
<?php $con = mysql_connect("localhost", "user", ""); if (!$con) { die('could not connect: ' . mysql_error()); } mysql_select_db("university", $con); $res = mysql_query("insert users (username, password, email) values('{$_post['uname']}', '{$_post['pwd']}', '{$_post['email']}')"); if (!$res) { echo "mysql error ->" . mysql_error(); } else { echo '<script type="text/javascript">alert(\'regjistrimi u krye me sukses!\')</script>'; } ?>
this form in html. cant see may wrong
<div id="containt" align="right"> <form action="<?php echo $_server['php_self']?>" method="post" id="registration_form"> <table border="0"> <tbody> <tr> <td><label for="name">your name*: </label> </td> <td><input id="name" maxlength="45" name="name" type="text" /> </td> </tr> <tr> <td><label for="email">email*:</label> </td> <td><input id="email" maxlength="45" name="email" type="text" /></td> </tr> <tr> <td><label for="username">username*:</label> </td> <td><input id="username" maxlength="45" name="uname" type="text" /> </td> </tr> <tr> <td><label for="password">password*:</label></td> <td><input id="password" maxlength="45" name="pwd" type="password" /></td> </tr> <tr> <td align="right"><input name="submit" type="submit" value="regjistro" /></td> </tr> </tbody></table> </form> </div>
it looks trying 1 php file? best way break php file display form , php file handle submit logic, named submit.php or similar. , in form tag's action attribute, put "./submit.php"
-or-
if set on doing in same page, wrap of submit logic inside of if...
if(isset($_post['uname'])){ // write database inside of here }
that way, writing database if there in $_post array.
Comments
Post a Comment