jmcc Posted May 26, 2009 Share Posted May 26, 2009 Please help regarding blank DB entry. I use files to send registration. registration.php is the form and register.php is the post to DB script. Registration form ---- registration.php [<?php] session_start(); $username = $_POST['username']; $password = $_POST['password']; $email = $_POST['email']; $_SESSION['username_pos'] = $username; $_SESSION['password_pos'] = $password; $_SESSION['email_pos'] = $email; [?>] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>"> <table width="50%" border="0" align="center"> <tr> <td>Username</td> <td><label> <input type="text" name="username" id="username" /> </label></td> </tr> <tr> <td>Password</td> <td><label> <input type="text" name="password" id="password" /> </label></td> </tr> <tr> <td>Email</td> <td><label> <input type="text" name="email" id="email" /> </label></td> </tr> <tr> <td>Confirm</td> <td><label> <input name="button" type="Button" value="submit" onclick="document.location.href='register.php'" /> </label></td> </tr> </table> </form> </body> </html> Post to DB script register.php [<?php] require_once("connection.php"); // database connection session_start(); $username_pos = $_SESSION['username_pos']; $password_pos = $_SESSION['password_pos']; $email_pos = $_SESSION['email_pos']; $insert ="INSERT INTO `users` (user_name, user_password, user_email) VALUES ('".$_POST[$username_pos]."', '".$_POST[$password_pos]."', '".$_POST[$email_pos]."')"; $insert2 = mysql_query($insert); if(!$insert2) die(mysql_error()); echo 'Registration Successful, Welcome ' , $username_pos , '!!! You can now login to your new account.'; [?>] Quote Link to comment https://forums.phpfreaks.com/topic/159669-registration-form-problem-db-entry-empty-think-variable-passing-prob/ Share on other sites More sharing options...
trq Posted May 26, 2009 Share Posted May 26, 2009 Your form posts to itself, not another page. Quote Link to comment https://forums.phpfreaks.com/topic/159669-registration-form-problem-db-entry-empty-think-variable-passing-prob/#findComment-842130 Share on other sites More sharing options...
Adam Posted May 26, 2009 Share Posted May 26, 2009 Not to mention if you had it linked to the right page, you're trying to return the values like: $_POST[$username_pos] Which would equal to: $_POST[$_SESSION[$username]] Try instead, though baring in mind you should really secure your inputs, something like this: $_POST['username'] Quote Link to comment https://forums.phpfreaks.com/topic/159669-registration-form-problem-db-entry-empty-think-variable-passing-prob/#findComment-842135 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.