Jump to content


Photo

Data not retrieved from form...


  • Please log in to reply
4 replies to this topic

#1 Cagecrawler

Cagecrawler
  • Members
  • PipPipPip
  • Advanced Member
  • 247 posts

Posted 24 October 2006 - 10:23 PM

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:
The Register Form
<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>

The PHP 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 filled
if(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 DB
include('include/connect.php');

//Insert data
mysql_query("INSERT INTO users(id,username,password,email,date) VALUES ('','$username','$password','$email','$date')") or die(mysql_error());

//Take to login page
echo("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.");
}
}
?>

Thanks in advance...

#2 kirk112

kirk112
  • Members
  • PipPipPip
  • Advanced Member
  • 98 posts
  • LocationEngland

Posted 24 October 2006 - 10:30 PM

before you entered the values into the database try echoing them out to make sure that are not null or empty

#3 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 24 October 2006 - 10:32 PM

Try debugging the variables...

<?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...
?>


#4 gmwebs

gmwebs
  • Members
  • PipPipPip
  • Advanced Member
  • 174 posts
  • LocationLondon

Posted 24 October 2006 - 10:32 PM

great minds kirk112 ;)

#5 Cagecrawler

Cagecrawler
  • Members
  • PipPipPip
  • Advanced Member
  • 247 posts

Posted 24 October 2006 - 10:39 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users