Cagecrawler Posted October 24, 2006 Share Posted October 24, 2006 I have written my own script for registering on my website, but when somebody registers, their details aren't stored in my database properly. I've worked out that the data isn't being retrieved from the form, but I have no idea why. $date is still being inserted into the database, so this confirms the fact that its a problem with the form. Below is my code:[u]The Register Form[/u][code]<form action="regprocess.php" method="post"><table><tr><td colspan="2"><center>REGISTER</center></td><tr><tr><td>Username:</td><td><input type="text" name='post_user'></td></tr><tr><td>Password:</td><td><input type="password" name='post_pass'></td></tr><tr><td>Repeat Password:</td><td><input type="password" name='repeat_pass'></td></tr><tr><td>Email Address:</td><td><input type="text" name='post_email'></td></tr><tr><td><input type="submit" value="Submit" name="Submit"><input type="reset" value="Reset" name="Reset"></td><td></td></tr></table></form>[/code]The PHP Code[code]<?php//Get form data + date$username = $_POST['post_user'];$password = $_POST['post_pass'];$repeatpass=$_POST['repeat_pass'];$email=$_POST['post_email'];$date = date('j-n-y');//Check all fields have been filledif(empty($username)|| empty($password) || empty($repeatpass) || empty($email)){//Kill script. Go fill in all the fields...die("All fields need to be filled. Please go back and try again");}else{if($password == $repeatpass){//Connect to DBinclude('include/connect.php');//Insert datamysql_query("INSERT INTO users(id,username,password,email,date) VALUES ('','$username','$password','$email','$date')") or die(mysql_error());//Take to login pageecho("Thank you for registering. You may now login <a href=\"login.php\">here</a>.");}else{echo("Passwords do not match. Please go <a href=\"register.php\">back </a>and try again.");}}?>[/code]Thanks in advance... Quote Link to comment Share on other sites More sharing options...
kirk112 Posted October 24, 2006 Share Posted October 24, 2006 before you entered the values into the database try echoing them out to make sure that are not null or empty Quote Link to comment Share on other sites More sharing options...
gmwebs Posted October 24, 2006 Share Posted October 24, 2006 Try debugging the variables...[code]<?php<?php//Get form data + date$username = $_POST['post_user'];$password = $_POST['post_pass'];$repeatpass=$_POST['repeat_pass'];$email=$_POST['post_email'];$date = date('j-n-y');echo $username;echo $password;echo $repeatpass;echo $email;exit(); //This exits the script so you can see the output...?>[/code] Quote Link to comment Share on other sites More sharing options...
gmwebs Posted October 24, 2006 Share Posted October 24, 2006 great minds kirk112 ;) Quote Link to comment Share on other sites More sharing options...
Cagecrawler Posted October 24, 2006 Author Share Posted October 24, 2006 Hmm...Well, it now works. I have no idea what I've done to make it work. But it works, so I'm happy...Thanks for the help. No doubt I'll be back sooner or later... :P Quote Link to comment 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.